I am trying to save a bitmap in the Pictures directory. Here is the code
File path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file = new File(path, "test1.PNG");
try {
path.mkdirs();
OutputStream out = new FileOutputStream(file);
mBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
Log.w("ExternalStorage", "Error writing " + file, e);
}
But execution got stuck in OutputStream out = new FileOutputStream(file);
I used a debugger, and the full path returns mnt/sdcard/Pictures/test1.PNG, is the mnt/culprit, why couldn’t I pass by OutputStream out = new FileOutputStream(file);? Because I can only see sdcard/in my file directory.
thank!
source
share