The correct way to load files from a library is with anywheresoftware.b4a.objects.streams.File.OpenInput.
anywheresoftware.b4a.objects.streams.File.OpenInput deals correctly with standard files, assets files and virtual assets file (new to v3.50).
Starting from v3.50 the rapid debugger uses a virtual assets folder. This allows the debugger to only redeploy updated files. This means that if you try to directly load a file from the assets file then it will fail.
Calling File.OpenInput will work correctly and will return an InputStream which you can work with.
In some rare cases (sound related APIs for example) the API requires a FileDescriptor. In this case you need to check whether a virtual assets folder is used and then either load the standard file or load the asset file.
For example: SoundPoolWrapper.Load
anywheresoftware.b4a.objects.streams.File.OpenInput deals correctly with standard files, assets files and virtual assets file (new to v3.50).
Starting from v3.50 the rapid debugger uses a virtual assets folder. This allows the debugger to only redeploy updated files. This means that if you try to directly load a file from the assets file then it will fail.
Calling File.OpenInput will work correctly and will return an InputStream which you can work with.
In some rare cases (sound related APIs for example) the API requires a FileDescriptor. In this case you need to check whether a virtual assets folder is used and then either load the standard file or load the asset file.
For example: SoundPoolWrapper.Load
B4X:
public int Load(String Dir, String File) throws IOException {
if (Dir.equals(anywheresoftware.b4a.objects.streams.File.getDirAssets())) {
if (anywheresoftware.b4a.objects.streams.File.virtualAssetsFolder != null) {
return Load(anywheresoftware.b4a.objects.streams.File.virtualAssetsFolder,
anywheresoftware.b4a.objects.streams.File.getUnpackedVirtualAssetFile(File));
}
return getObject().load(BA.applicationContext.getAssets().openFd(File.toLowerCase(BA.cul)), 1);
}
else {
return getObject().load(anywheresoftware.b4a.objects.streams.File.Combine(Dir, File), 1);
}
}