On Thursday, January 31, 2013 7:31:09 PM UTC+11, Richard Jones wrote:
I'm transitioning an app over from the pygame subset for android (pgs4a) to Kivy and in doing so the default location for file storage has changed. In my app I save the game state using:
with open('save.state', 'wb') as f:
marshal.dump(state, f)
Under pgs4a this is saved in /data/data/net.mechanicalcat.match3/files/save.state but under the latest python-for-android that Kivy uses it's saved under /storage/emulated/0/net.mechanicalcat.match3/save.state.
That's not necessarily a problem *except* that I can't seem to retain existing players' game state when I upgrade from pgs4a to python-for-android. The save.state file under the old files directory appears to be deleted when the new APK is installed. The file is *not* deleted when I install an APK that represents a new version of the pgs4a game.
I have discovered the cause of the problem. Both use the renpy Java runtime.
pgs4a bundles all of the application data into the private.mp3 archive. This is installed into /data/data/net.mechanicalcat.match3/files/.
python-for-android bundles some of the application into private.mp3 and some into public.mp3. The private data goes into the directory above. The public data goes into the directory defined by getExternalStorageDirectory() which is /storage/emulated/0/net.mechanicalcat.match3/. I'm *still* hazy on the details here but I *believe* that's just an alias for /data/data/net.mechanicalcat.match3/.
The problem is that in both cases the target directory is recursively deleted first - that public data storage is forcefully cleaned. Save games, whatever, are lost.
It's late here, so I've not trawled through the logs to try to determine why the public.mp3 is used: does anyone know? And would you object if I submitted a change to undo it?
Richard