I have many files within my app that get moved to DirInternal on install. I would like to offer the option to backup these files if the user decides to uninstall the app, or (like several who have emailed me) for users who wipe their phones/devices frequently. My question is where is a place that I can backup these files too that won't get deleted if a user uninstalls the app? I plan on offering the user the option to backup to Internal memory and/or External. I am guessing I would need to use MakeDir, but I'm not sure where a safe place for the files are. Can anyone help?
You can most times do something like this: File.ListFiles("/mnt"). This will show the directory structure of the device. On my device I see directories like:
/mnt/media
/mnt/sdcard
You can then make a directory like you App name on one of these like:
/mnt/sdcard/myappname/backup/data
Then copy all the data to that directory. If the user uninstalls your app this directory will not be deleted.
You can most times do something like this: File.ListFiles("/mnt"). This will show the directory structure of the device. On my device I see directories like:
/mnt/media
/mnt/sdcard
You can then make a directory like you App name on one of these like:
/mnt/sdcard/myappname/backup/data
Then copy all the data to that directory. If the user uninstalls your app this directory will not be deleted.
Hmm, actually I am running into problems. Here is my code:
B4X:
File.MakeDir("/mnt","appname/My Backup")
Log(File.ListFiles("/mnt/appname/My Backup"))
For i=0 To FileList.Size-1
File.Copy(File.DirInternal,FileList.Get(i),"/mnt/appname/My Backup",FileList.Get(i))
Next
Log(File.ListFiles("/mnt/Jonsap/IV Drips"))
For the first Log it is stating that the directory doesn't exist. Then on the File.Copy line I get an error because the directory is invalid. And yes, I confirmed there are many files in DirInternal. Any ideas?
I see, I was wondering what mnt was exactly. What I am actually trying to do is copy the files to a directory on internal memory. Is there a universal path for this?
I always use file.DirRootExternal for custom paths on the sdcard (internal memory)
file.DirDefaultExternal is your apps data path on the sdcard (internal memory).
Do a Log of both to see where they are pointed to.
/mnt is a directory on linux/android where you can see all storage devices mounted.
I always use file.DirRootExternal for custom paths on the sdcard (internal memory)
file.DirDefaultExternal is your apps data path on the sdcard (internal memory).
Do a Log of both to see where they are pointed to.
/mnt is a directory on linux/android where you can see all storage devices mounted.
Maybe Erel can confirm for us soon. Does DirDefaultExternal get deleted when the app is uninstalled?
Edit:
Well I just made an emulator with no SD card support, and DirRootExternal fails because it tries to write to /mnt/sdcard/.
Basically all I need is a fail-safe Internal directory that I can copy files to on any device. Help?
I would think that DirDefaultExternal would be removed because itn't it tied to your application directly?
Is there a way to see the contents of the dir from a pc or mac? Like I can on my windows phone?
I don't yet have a real device to check all this out. My samsung galaxy s2 is coming in the next few days.
If there's a way to independently look at a dir's contents you could install your app on your device, look that it's there. Do the backup then uninstall and look to see if it's still there.
Being a newbie to android I guess it's not as easy as that.
Tested it on the emulator and it appears that the files in DirRootExternal are saved after an uninstall. Again problem lies with devices that do not have "external" storage (like this emulator I created with no SDcard support). I cannot copy files to DirRootExternal on this emulator.
So Erel can you help? I am looking for the directory path on internal memory that I can copy files to that won't get delete. This is for devices that don't have any "external" memory.