I'm using Flutter-SQLite-Dart to develop a mobile application that has basic functionality just as Quiz application. I store questions and answers to my local database, when cache is cleared then the stored data gets erased. I need to save those data without getting lost. What methodology to use for achieving a solution for this issue?
1 Answers
For Android, you have two options in App info - clear data(clear storage) and clear cache.
By default, SQLite DB is saved in the internal app data directory, so when you clear the cache(app cache directory), all your DB data are still alive. But if you clear data(clear storage) you remove your DB + cache + other data.
If you want to keep DB after clear data(clear storage) or uninstalling the application, you have some options:
Auto Backup for Apps automatically backs up a user's data from apps that target and run on Android 6.0 (API level 23) or higher. Android preserves app data by uploading it to the user's Google Drive—where it's protected by the user's Google account credentials. The amount of data is limited to 25MB per user of your app. There's no charge for storing backup data. Your app can customize the backup process
- You can try to change the DB saved directory. For example, save it to Documents or so.
- Use firebase_database
All those options have pros and cons...
And pay attention please, when the user will try to clear app data, Android will show an alert dialog with the next information:
All this app's data will be deleted permanently. This includes all files, settings, accounts, databases, etc.

- 117
- 1
- 9

- 1,216
- 10
- 12
-
Thank you so much for your answer. Will try these suggested options – Terin Tittu Nov 22 '21 at 09:07
-
@TerinTittu Glad to help) – Eugene Kuzmenko Nov 22 '21 at 10:12