Android File System
Today I am working out the file system for Android applications. In the past we just manually copied all our assets to a "/Leadwerks" folder on the device itself. This approach is okay for testing, but it won't work for distributing apps in the Google Play store.
Android uses APK files to store all applications in. An APK file is really just a ZIP file, and all your assets go in a /res/raw directory in the ZIP package.
To access the Android file system from C++, we had to take the following steps:
1. Retrieve the file path to the application APK file (with Java).
2. Pass this file path to C++.
3. In C++, load the APK file as a standard zip package.
4. Change the current directory to the APK folder path + "/res/raw".
All this occurs before the App::Start() function is called, so as soon as you start, you're ready to access all the files your game needs.
It's nice when things work out neatly like that.
1 Comment
Recommended Comments