file deleted when opening app very fast at android's startup

mc73

Well-Known Member
Licensed User
Longtime User
Dear friends,

not very relevant to this forum, but I thought to let you know something I've discovered. When we run an app immediately at android's startup (I use 2.3), and there is a check for file.exists in our activity_create, since android is still scanning its media library (I thought this had to do just with the media lib), file.exists returns a false, thus pushing my app to place a fresh copy of my db from dir.assets. I solve this by simply adding a small counter, and exiting the app when file.exists returns false, just to let android take its time and finish with scanning. Of course there can be other ways, I chose this just to discourage users from trying to run the app very very fast.

PS: we're talking about external dirs.
 

thedesolatesoul

Expert
Licensed User
Longtime User
I face a similar issue when my service starts at boot. The sdcard scanner has not finished so the external storage is not mounted yet.
This problem will also happen if the storage is mounted as USB mass storage and some one tries to access your app.
I am not sure what the correct solution is but you can differentiate between File.Exists and File.ExternalReadable/File.ExternalWritable so that you know whether the issue is of the sdcard or whether the file actually does not exist.
 
Upvote 0

mc73

Well-Known Member
Licensed User
Longtime User
I face a similar issue when my service starts at boot. The sdcard scanner has not finished so the external storage is not mounted yet.
This problem will also happen if the storage is mounted as USB mass storage and some one tries to access your app.
I am not sure what the correct solution is but you can differentiate between File.Exists and File.ExternalReadable/File.ExternalWritable so that you know whether the issue is of the sdcard or whether the file actually does not exist.
Sure you can do that, it's just that in my case, my app is installed in devices I handle, so some things are already handled manually :)
 
Upvote 0
Top