2

I need to distribute an application on Google Play. However, my application has a library that accesses 10 ".dat" files. The problem is that distribute these dats files. In the assets directory i tried unzip, but, the library ".so" cannot access them: permissions issues.

I thought about the possibility of putting them in the raw directory, but I do not know if it would work, because I use the NDK to make the link and do not know if it would have the lib directory permissions on this project.

Would not nice store in sdcard. The user could delete the files...

What should I do?

Mateus
  • 389
  • 3
  • 20
  • 1
    You can [read assets from native code](http://stackoverflow.com/questions/11793677/file-acess-on-android-app-when-using-android-ndk/11797928#11797928). Or you can copy them to a data folder on the first run. – Seva Alekseyev Aug 28 '12 at 14:01
  • Seva, Thanks for the reply. It happened two problems: to make a copy of all the files, they were all the same size (do not know why. Has any idea?). Also the APK is already with 20MB with these dats what can be bad copy them to another directory, do not you think? The good thing about this story is that if I copy the user delete them... Can you help me? – Mateus Aug 28 '12 at 16:29
  • If the data files lend themselves to compression, the APK won't be 20 MB. For expanding them though, you might want to consider SD card (if it's present). As for user deletion, the copying has to be conditional anyway - you copy the files into a directory if they're not already there (i. e. it's the first run), so if the user deletes, they can be copied over. By the way - is it YOUR library? Because the best way would be - just reading them from the APK as assets. – Seva Alekseyev Aug 28 '12 at 17:04

1 Answers1

2

Put all your .dat files into the assets folder (at the same level where you have src and jni). Ant will pack them into the .apk archive.

If you target Android 2.3+ you can access your files directly with NDK calls. If you want to run on lower versions of Android your have 2 possibilities:

  1. Extract files to SD-card via Java and then access them from native code.
  2. Use minizip (or similar zip unpacker) to access the files within the .apk archive
Sergey K.
  • 24,894
  • 13
  • 106
  • 174