I modified some code to write a Bitmap to internal storage (Android) that previously wrote to external storage successfully. But compress() is now returning false. Unfortunately the docs do not describe conditions that are likely to cause this, and of course since no exception being thrown there's no help there.
Below is my code.
// Only change made was to the line immediately below, now commented out
// File directory = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES + "/AIL_SCANS"); //Creates app specific folder
File directory = contextIn.getDir("my_pics", Context.MODE_PRIVATE);
if (!directory.exists())
directory.mkdirs();
File file = new File(directory, sFilenameIn + ".jpg");
FileOutputStream os = new FileOutputStream(file);
if (!imageIn.compress(Bitmap.CompressFormat.JPEG, 100, os))
Log.e("Error", " compress() failed (returned false)");
os.flush();
os.getFD().sync();
os.close();
Log.e("Success", " Profit!!");
My code created the Bitmap as ARGB_8888 (see below) so a couple of other Stack Overflow posts reporting a similar failure do not seem to apply here.
bmp = Bitmap.createBitmap(arrPixels, widh, height, Bitmap.Config.ARGB_8888);
An example of some code that apparently has worked well for a large number of Stack Overflow users looks almost exactly like mine. Saving and Reading Bitmaps/Images from Internal memory in Android