在SD卡中保存多张不同名字的图片
问题描述:
我正在做一个程序,你可以在手机上绘制你的签名。现在它可以保存一张图片,但我想要保存多张图片,因为有多个客户需要在其包装上签名。非常感谢任何形式的帮助。在SD卡中保存多张不同名字的图片
public void save() {
File sdImageMainDirectory = new File("/sdcard/mySignatures");
sdImageMainDirectory.mkdirs();
String nameFile = "newpic";
FileOutputStream out = null;
try {
out = new FileOutputStream(sdImageMainDirectory.toString() +"/" + nameFile + ".jpg");
mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.flush();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
out=null;
}
答
很明显,你需要改变文件名为每个独特的东西。顺序编号将起作用。或者让用户输入一个名称并验证其是否合法。