I am trying to access photos saved in the assets folder, my code doen't work all the times.
i have 16 sub-folders in assets with photos in png format each have between 30kb ~ 60kb
Each folder have between 100 and 400 photos
Full size of assets folder is 113mb.
My code stoped working when i added more photos to the assets
public Bitmap getImg(String ID, String pic){
InputStream istr = null;
try {
//Exemple: II/1.png
istr = getAssets().open(ID + "/" + pic +".png");
} catch (IOException e) {
e.printStackTrace();
}
return BitmapFactory.decodeStream(istr);
}
When i run this code i get a FileNotFoundException, but the file existis (i am awere that file names are case sensitive, extension is in lowercase and pic names are numbers).
I think this is something to do with the file size, because i compressed all photos in one of the subfolders and it started to work again, but on the other folders (that have alot more photos) don't, even after compressing i keep getting a FileNotFoundException.
is there a better way to store or access the photos?
I was able to fix my issue by changing the format from PNG to JPG