Android Assets with sub folders

前端 未结 4 1706
暗喜
暗喜 2020-12-03 02:53
InputStream myInput = myContext.getAssets().open(\"MyFolder/\" + \"MyFile.db3\");

I have a file in the assets folder in a sub folder as above. It d

相关标签:
4条回答
  • 2020-12-03 03:28

    I had a similar issue: Changed the subfolder name from "mp3" to "mpthree" and the files were found.

    0 讨论(0)
  • 2020-12-03 03:29

    Is your asset file over 1 MB?

    I notice that I get the same odd, empty IOException if I try to open an asset that is over this size. The fact that it is in a subfolder could be a red herring. I'm trying to open a large text file so I can workaround this limit by splitting it up. Can you do something similar with your .db3 file?

    0 讨论(0)
  • 2020-12-03 03:33
    "MyFolder/" + "MyFile.db3"
    

    A filename for files added to the assets folder must be in lowercase letter. so,a filename such as MyFolder and Myfile.db3 is invalid. Rename them to "myfolder" and "myfile.db3",then everything will be fine.

    0 讨论(0)
  • 2020-12-03 03:35

    Edit: was wrong about subfolders.
    This code works just fine on 1.5 (for a file sample.txt placed under sub folder in assets):

    InputStream is = getAssets().open("sub/sample.txt");
    BufferedReader br = new BufferedReader(new InputStreamReader(is));
    String line = null;
    while ((line = br.readLine()) != null) {
        Log.e("wtf", line);
    }
    br.close();
    

    Are you sure you've got the names right?

    0 讨论(0)
提交回复
热议问题