Can’t find file when loading from Assets?… here is a solution to the problem.
Can’t find file when loading from Assets?
I included several pre-made .png files in my Assets folder, but only some of them are error-free :
AssetManager assetManager = context.getAssets();
Inputstream in = assetManager.open(assetName);
where assetName
is a String
that contains something like “myPic.png”.
It seems to work for some files, but for others it throws java.io.FileNotFoundException: myPic.png
Even though I see it in the Assets folder along with many other files, it seems to be a success.
Solution
Obviously, closing/reopening the project in Android Studio is enough for it to work. Not sure why it didn’t notice all Assets at first, but now it notices after rebooting.