tags:

views:

146

answers:

2
        AssetManager assets = myContext.getAssets();
        String[] files = assets.list("MyFolder");
        InputStream myInput = assets.open("MyFolder/" + files[0]);
        int i = myInput.read();

in this case 'i' is -1 meaning nothing read.

Why would nothing be there if the file is there, the variable 'files' has the file as well.

Do I need to do anything to the file I put into the Assets folder in get it to be readable?

NOTE: When I use a small text file it works. When I use a 10 meg file, it does not. (The 10 meg is a Sqlite database I need to install)

A: 

You cannot put a 10MB file inside an APK. You will need to slice that into 10 1MB files. Better yet, distribute the database in some other way, such as downloading it to the SD card on the first run of the application. Many users will be unable to install your APK if it is that large.

CommonsWare
I found a post by a google engineer that says that the issue is because the system zipped resources and can't unzip a file larger than 1 meg. The solution is to rename your database to XXXXX.png so that it is not compressed. Then it all works fine.
BahaiResearch.com
Ah, right, I had forgotten about the fake-file-extension trick. My apologies.
CommonsWare
+1  A: 

Rename the file to XXXXXX.png so that it is not compressed, then it can be copied over.

BahaiResearch.com