Question

        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)

Was it helpful?

Solution

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

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top