In my android project I have created an assets folder in which I have added some json files and I want to read them with a stringBuffer. The assets folder is listed inside src/main. So far I have added the following code:
String[] files = assetManager.list("");
ArrayList<String> it = new ArrayList<>(Arrays.asList(files));
And so far I am getting the names of the files successfully inside my ArrayList. Then I am trying this:
InputStream input = assetManager.open("filename.json");
But I get the following error:
Failed to open file
‘/data/data/package/code_cache/.overlay/base.apk/assets/filename.json’:
No such file or directory
I also have included the follwing permission in the manifest:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Any idea what might be the problem here?
2
Answers
You can clear storage in device and then rebuild app, that help my same issue.
I got the same issue on my Android project many times. Try uninstalling the app on your emulator and rebuild your app.