I first wrote my app in Java a while ago, and I used the app's internal storage for saving lists of players and some DLC. The structure on an Android device looked like:
ca.bigbeanbag.myapp / files / backup / playerbackup.xml
I have now completely rewritten the app in Flutter (so I can also release on iOS), and I would like to be able to migrate the player backup from the java version. It seems that flutter uses a different starting point for internal storage (it adds folder app_flutter first). On a device that was upgraded from the java version to the flutter version, the tree looks like:
ca.bigbeanbag.myapp /
.. app_flutter/files/backup <-- new flutter storage location
.. files/backup <-- old java storage location
So on first run of the new flutter version of the app, I just use the parent to find my way to the java-version files, and import them over to the new flutter storage location
var docsDir = await getApplicationDocumentsDirectory();
String oldBackupPath = docsDir.parent.path + '/files/backup/backup.xml';
String destinationPath = docsDir.path + '/files/backup/';
... and copy
In debug mode on the emulators, this works great.
However on a real device, when I get a directory listing of the old java folders (ca.bigbeanbag.myapp/files) instead of what I get when on emulator/debug mode:
ca.bigbeanbag.myapp/files/
.. backup
.. dlc_stuff
I get this instead:
ca.bigbeanbag.myapp/files/
.. rList
.. generatefid.lock
.. PersistedInstallation.W0RFRkFVTFRd+(lots of letters).json
So in reelase on a real device I can't access the internal storage of the older java version.
I'm not sure what else to do at the point. Hoping someone will have some ideas / guidance.
I never found out exactly why I wasn't getting access to the java internal storage area from the new flutter/dart version, but I did discover it has something to do with using a relative reference.
In the flutter version the internal storage is stored under 'app_flutter', and hopping up to the parent and down to the java-app created folder like this:
var docsDir = await getApplicationDocumentsDirectory();
// docsDir now equals "../ca.bigbeanbag.net.myapp/app_flutter/"
String oldBackupPath = docsDir.parent.path + '/javafiles/backup.xml';
doesn't work. However if I reference the java-app created folder all the way from the top:
/sdcard/Android/data/... .../ca.bigbeanbag.myapp/javafiles/
it worked ok and I was able to read javafiles.
Hope this helps anyone else. Thanks to anyone that read the question.