Unsolved Android (and iOS) Local Storage Disappearing
-
Android Customers reported that when updating from V1.1 to V1.2 that the Google update process wiped their device local storage.
V1.1 was built with Qt version 5.8. V1.2 was built from Qt version Qt 5.10.1 (Clang 8.0 (Apple), 64 bit)
It is my understanding that the device local storage is to remain intact from one version to another. The only thing to erase device local storage is an uninstall..either the Play Store Uninstall or the Android App Setting Uninstall/Clear Storage.
https://developer.android.com/guide/topics/data/data-storage
In researching..
https://stackoverflow.com/questions/7750857/how-permanent-is-local-storage-on-android-and-ios“localStorage can be wiped out by the OS (android,ios) at any time. This is really serious if you care about data persistence.”
There appears to be a conflict with what the Android and iOS documentation says and what developers are reporting. Which is correct?
Some of my customers replied to my e-mail queries regarding this issue and admitted they did, in fact, uninstall their app. Other customers adamantly claimed the only thing they did was update to the new version. Releasing V1.2 caused a shitstorm of negative reviews. It forced me to make refunds to unhappy customers. There is no way to reply or explain a negative review in just 350 characters.
I would like to NOT go through this each time a new release is made.
I can see how a package name change could cause issues with local storage, the app package name in the Android manifest file did not change from V1.1 to V1.2.
What am I missing on the local storage issue?
If iOS randomly reclaims app local storage, then using it for things you expect to be there until uninstalled makes absolutely zero sense. If Android now does this too, the same goes for local storage on Android devices.
What are people doing to avoid this obvious pitfall / limitation? Use SD card storage on Android? What if the Android device has no SD card or the API/OS level does not support installing the app to the SD card? Android 8.0 on allows this with the correct Manifest File Setting..but there does not appear to be something accessible to modify in Qt Creator. What do you do on iOS?
-
@PSI_lbc I'm always storing my app data here:
// Android: AppDataLocation works out of the box, iOS you must create the DIR first !! mDataRoot = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0); mDataPath = mDataRoot+"/data/";
never had any problems of missing data after updating the app
-
@ekkescorner said in Android (and iOS) Local Storage Disappearing:
Thanks for the reply. Your code generates this..
QString mDataRoot = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).value(0); QString mDataPath = mDataRoot+"/data/"; qDebug() << mDataPath ; Output: "/data/data/com.company.app.name/files/data/"
I'm already using something similar..
QString dataPath = QStandardPaths::writableLocation(QStandardPaths::DataLocation); qDebug() << dataPath ; Output: "/data/data/com.company.app.name/files"
..a closing "/" is added later to the path.
For iOS, output for your way is..
"/var/mobile/Containers/Data/Application/longapp#?/Library/Application Support/CompanyName/AppName/data/"
And I'm using this..
QString docsPath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); qDebug() << docsPath ; Output: "/var/mobile/Containers/Data/Application/longapp#?/Documents"
..a closing "/" is added later to the path.
Not sure if your way would be better fo iOS. I don't remember why I decided to use the different standard documents path for my iOS app versus the standard data path.
-
Hi,
This happened also to my app after an app update but only on iOS.
Many customers started to write negative reviews because they lost their settings.
I've published this app 5 years ago and I've done lots of updates but this is the first time I've this big issue.Settings are stored in the path returned by:
QStandardPaths::writableLocation(QStandardPaths::DataLocation)I've done some tests by installing the old app version using xcode and the updating it (always from xcode) but I'm not able to reproduce it.
The only "ios level" big thing I've modified is the support of push notifications, so I've added them to the app entitlements.
Could that be the problem? -
@GBergamo said in Android (and iOS) Local Storage Disappearing:
Settings are stored in the path returned by:
QStandardPaths::writableLocation(QStandardPaths::DataLocation)You don't use https://doc.qt.io/qt-5/qsettings.html ?
-
I'm using qsettings as ini files in that folder. Moreover I'm also storing sqlite databases and json configurations files. All of them disappeared after the update.