I drive an array of int values into a file, which is a photo with the extension * .jpg
File newFile = aFile; FileOutputStream file = new FileOutputStream(newFile); for (int i = 0; i < icon.length; i++) { file.write(icon[i]); // icon[i]- int value } file.close();
The problem is that the OS android does not define the created file as a picture and gives it an empty icon (as for an undefined file), while for other files (jpg, png, etc.), a thumbnail of the picture itself is given instead of the icon. Also, this file does not open in the gallery - a standard application on the tablet. At the same time, if you select 'open file as image' in the menu item, it opens in the standard viewing window, the file also opens in a third-party image viewing program.
I can not figure out what I forgot to specify when saving to a file.
OutputStream.write(int)
writes only the lower 8 bits (1 byte) of the argument to the file, perhaps this is the problem. Try wrapping thefile
into aDataOutputStream
and callingwriteInt
. This may also not solve the problem, because there may be a wrong writing order (writeInt writes high bytes ahead). How do you get the array to write? - zRrr