Reputation: 2882
I have a class which write a png in the internal storage. When I write and read it just after that, it works.
FileOutputStream fileOutStream = openFileOutput(filepath,
Context.MODE_PRIVATE);
mBitmap.compress(Bitmap.CompressFormat.PNG, 90, fileOutStream);
fileOutStream.close();
(the type of Bitmap is a Bitmap)
FileInputStream fileInStream = openFileInput(filepath);
byte[] fileContent = org.apache.commons.io.IOUtils.toByteArray(fileInStream);
When I use the same read function, with the same filepath parameter (I verify id), but in another class, it doesn't work.
Is there a limitation when using with another class of the same project ?
Regards
Upvotes: 0
Views: 382
Reputation: 17813
Are you sure there is only one underlying stream on this file? because if you have multiple stream and call close() method, this will enforce to close all other streams.. so correct implementation is to close the last stream or apply flush to each one .. and close the last .. btw: for a single process of stream writing there is no need to explicitly call flush() method, because close() methods will call it implicitly.
Upvotes: 1