Cómo distribuir los archivos ".dat" a los que accede la biblioteca .so

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...

¿Qué debo hacer?

preguntado el 28 de agosto de 12 a las 14:08

Puede read assets from native code. Or you can copy them to a data folder on the first run. -

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? -

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. -

1 Respuestas

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

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. Utilice las minizip (or similar zip unpacker) to access the files within the .apk Archivo

Respondido el 13 de Septiembre de 12 a las 10:09

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.