[SOLVED] How to apply data access for my apk?

Hello, after adding a Nifty gui page for the highscore, I stored the data in a file in the builddirectory. Startet from the JME SDK or fom a runable jar it works fine, but when I port the game to Android it doesn’t. Because I worked with conditions like file.exist() or file.canWrite() the Application still runs but the highscore table didn’t works. So how can I bring my App to ask for data access? Or is there a directory in my project where my App don’t need to ask?

This is Android related, not JME. You have to request permission to read/write to internal storage, and then use their API to read/write those files.

https://developer.android.com/training/permissions/requesting

https://developer.android.com/training/data-storage/

You can branch your workflow from desktop to Android by checking the platform if memory serves using JmeSystem.getPlatform(). Something like this off the top of my head…

if (JmeSystem.getPlatform().toString().startsWith("Android")) {
  // I'm on android
}
else {
 // I'm not on android
}
1 Like

Thanks, this is exactly what I thought I need. I changed the Andoid manifest as described in your link and atfter installing the apk I was ask to grant the data access. But strangly, the Highscore table still seems not to work, so i have to lock for another cause. But not today…

1 Like

Rollback my Last Message. I tried to set the path for my file to “/storage/emulated/0/” when the App runs on Android instead of a relative path to my App (as I do otherwise) and the highscoreslist works. So I think I’ve found something, to look further on tomorrow

1 Like