• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

getAssets().openFd() throw exception

ottersss

Lurker
Hello all,
I place 2 files in assets folder
  • res.bin (650 MB)
  • res_LITE.bin(200 MB)
Then i use getAssets().openFd("filename") to load these files, but i have a trouble.
  • In Android version 8,9,10,11,12,13: It was fine
  • In Android version 6,7 (Nexus 6 - Android 6.0.1, Samsung J2 Pro - Android 7.1.1):
    • For "res_LITE.bin": Load success
    • For "res.bin": I got an exception "java.io.FileNotFoundException: res.bin"
Can anyone please explain why it thow exception? (I guess cause of large file but I'm not found information about that)
Thanks a lot! :)
 
Have a test to verify the cause of large file at first.

copy res_LITE.bin res.bin
getAssets().openFd("res.bin")
check whether you will get the FileNotFoundException again.
 
For your recommend, No exeption.
It seems that the AssetManager compressed the large asset file when you built for Android 6/7.
Place that files in res/raw folder instead of assets folder, and get it in your code like this:
activity.getResources().openRawResourceFd(rawId);
 
It's a good idea but unfortunately i need place that files in assets folder cause i using "play asset delivery" feature
 
Back
Top Bottom