There is a code:

try { FileOutputStream fos = new FileOutputStream("/sdcard/Android/data/ru.vspr/data/sct.jpg"); mBitmap.compress(Bitmap.CompressFormat.JPEG, 100, fos) } catch(Exception ex) {} 

Why not create a folder and file (by default they are missing)? Everything works if you select / sdcard / as the path. How to solve this problem?

  • Because the folders must exist. create the whole path first except the files. - Chad
  • How to create a path? I hope not by hand - Helisia
  • Google to help you - Chad
  • 2
    File.mkdirs() - falstaf

1 answer 1

Saving image to file:

 try { FileOutputStream fos = new FileOutputStream(Environment.getExternalStorageDirectory() + "name.jpg"); mBitmap.compress(CompressFormat.JPEG, 75, fos); fos.flush(); fos.close(); } catch (Exception e) { Log.e("SuperCreeper", e.toString()); } 

Do not forget to put in the manifest the recording resolution on the SD card.