I`m trying to save Bitmap image by this code:
File sdcard = Environment.getExternalStorageDirectory();
String filename = "test";
File folder = new File(sdcard, "/Download");
Log.v("ImageStorage1", "EXiST?: " + folder.exists());
folder.mkdirs();
Log.v("ImageStorage2", "EXIST!: " + folder.exists());
Log.v("ImageStorage", "Folder: " + folder);
File file = new File(folder, filename + ".jpg");
try {
FileOutputStream out = new FileOutputStream(file.getAbsoluteFile());
result.compress(Bitmap.CompressFormat.JPEG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
I`m also using in manifests file:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But i`m getting this one:
V/ImageStorage1: EXiST?: true
V/ImageStorage2: EXIST!: true
W/System.err: java.io.FileNotFoundException:
/storage/emulated/0/Download/test.jpg (Permission denied)
W/System.err: at java.io.FileOutputStream.open0(Native Method)
W/System.err: at java.io.FileOutputStream.open(FileOutputStream.java:287)
W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:223)
W/System.err: at java.io.FileOutputStream.<init>(FileOutputStream.java:171)
Actually, my task is to store to another folder and when I`m using this:
File folder = new File(sdcard, "/kpi/test/a");
I`m getting
V/ImageStorage1: EXiST?: false
V/ImageStorage2: EXIST!: false
(No such file or directory)
Even with:
folder.mkdirs();
I tried a lot and surfed a lot, but haven`t found an answer :(