Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Some users report losing data

After a long time having an app run without any problems - I got a report form a user stating the data / photos saved was lost now and then. I.e. it may work initially, but at a later stage the content appear gone. I can not duplicate the problem, so I am trying to see if I can "guess" it.

First thing to ensure is that I am not saving data in a way that is somehow not feasible with recent Android versions. Hence here is how I currently save data:

...

First try

File storage_files_dir_file = ctx.getExternalFilesDir("");
if (storage_files_dir_file.exists() == false) {
  return false;
}
// ... some code here prepping content
os = new FileOutputStream(path_final,true);
// ... some code here writing content
MediaScannerConnection.scanFile(ctx, new String[] {s}, null, null);
return true

If the above returns false switch to

File storage_files_dir_file = ctx.getFilesDir();
if (storage_files_dir_file.exists() == false) {
  return false;
}
// ... some code here prepping content
os = new FileOutputStream(path_final,true);
// ... some code here writing content
return true

...

My AndroidManifest.xml includes

  <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

...

If indeed it is a file problem I see the following possibilities:

  • Data access issue?
  • The saved files get removed by Android?
  • 3rd party cleaning app?
  • Related to if running on phones with a SD card in bay?
  • Related to if running on phones with app installed on SD card in bay?
  • Phone running completely out of space?
  • New: Android 8 users deleting data and photos by accident?
  • New: Combination of Android 8 + e.g. either external app data or internal app data.

It is has been a long while since I coded the above - but I recall the ambition was to save the data at as permanent and accessible place as possible for easy backup.

...

My last update to the app was in March 2017.

Update

I am wondering if the culprit of the problem could be Android 8 Oreo. I have not had access to his myself yet, but from articles it seems it is now possible to delete photos across apps in one go? + I have seen screenshots where users can select to delete both app-data and app-cache? If this is the reason: Any difference if using external or internal app-data storage? Or way to prevent?

My app data is not affected by any cleanup app I have tried on Android 6 and Android 7, but I only tried a quite limited amount compared to all the different companies out there producing Android phones.

...

Does anyone know if it possible to get a file deletion log from users they can send? Maybe that would help diagnose the problem.

like image 564
Tom Avatar asked Apr 11 '18 14:04

Tom


People also ask

What is the most common reason for data loss?

Hard drive crashes account for the highest percentage of data loss, but human errors and issues with software follow closely behind. According to data from Kroll Ontrack: 67 percent of data loss is caused by hard drive crashes or system failure. 14 percent of data loss is caused by human error.

What is an example of data loss?

It may also occur due to physical damage or mechanical failure or equipment of an edifice. The biggest reasons for data loss include laptop theft, accidental deletion or overwriting of files, power outages and surges, spilled liquids, and the wearing out or sudden failure of hard drives.


1 Answers

Your problem sounds more like an external cleanup of any kind to be honest.

But anyway, maybe you want to take a look at this: We had issues with a file generated too since Android 8, I then came upon this article: https://developer.android.com/reference/android/support/v4/content/FileProvider.html

We changed our file access to be done via such providers and everything is fine since then. Hope this helps, Cheers Gris

like image 196
Grisgram Avatar answered Oct 07 '22 04:10

Grisgram