0
使用下面显示的代码来保存JPG文件到SD卡上点击按钮。如何在android中创建文件夹并将多个文件保存到该文件夹?
OutputStream fOut = null;
try
{
fOut = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
mMergedLayersBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
将图像保存到一个文件夹,我重写代码,如图波纹管
OutputStream fOut = null;
//Create Folder
File folder = new File(Environment.getExternalStorageDirectory().toString()+"/draw/Images");
folder.mkdirs();
//Save the path as a string value
String extStorageDirectory = folder.toString();
//Create New file and name it draw.jpg
File file = new File(extStorageDirectory, "draw.jpg");
try
{
fOut = new FileOutputStream(file);
mMergedLayersBitmap.compress(Bitmap.CompressFormat.JPEG, 85, fOut);
fOut.flush();
fOut.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
现在它改写图像当我点击保存按钮第二次。我想保存即将保存到文件夹的整个图像。我不知道如何更改我的代码以满足此要求。如果有人知道这件事,请帮助我..
更改此:' “draw.jpg”''到的String.format( “%D.JPG”,System.currentTimeMillis的()'在第二种方法中获得新的文件名。 –
谢谢Harry Joy ....我明白了.... – Binu