I use the ObjectBox in my kotlin project. Users can erase the database by clearing the application Data from the Android settings.
I want to prevent database removal or change ObjectBox Store mode to SQLite!
thanks
In case you want to make user data persistent you definitely should save and check DB copy on your server.
First of all, as you probably know, this is "normal" behavior on Android. When you delete an app's data, you have to start from scratch. E.g. all local data lost and log-in again etc. I'd guess that 0.01% of users would actually know about it and actually do that.
Anyway, yes, the question is if you want to extend data scope to cloud/server... That's a different topic though. ObjectBox will offer data synchronization later this year.
Alternatively, there's also Android's backup function: https://developer.android.com/guide/topics/data/autobackup.html
Related
My app tracks school grades, calculates averages, etc. and stores all of this in a SQLite database. If a user has to reinstall or gets a new phone, I'd like to be able to restore their data.
It looks like most developers do this either by backing up to SD card or by using Android Backup Service through Google. I'm not sure which is the better method. I'd like restoring to be simple but reliable. I welcome any comments on this.
One thing I'm trying to understand is why Google says to extend BackupAgent instead of BackupAgentHelper if using a database.
If you have an SQLite database that you want to restore when the user re-installs your application, you need to build a custom BackupAgent that reads the appropriate data during a backup operation, then create your table and insert the data during a restore operation.
Why can't I just back up the database as a file and then restore the file? My SQLiteOpenHelper class already handles upgrades if db versions are different. I guess I could just abort on a downgrade.
Why can't I just back up the database as a file and then restore the
file? My SQLiteOpenHelper class already handles upgrades if db
versions are different. I guess I could just abort on a downgrade.
Reason: same database file may not work on different device models(even though most of the cases, it should work, there are cases where it will fail). It depends on parameters like page size etc set at sqlite engine level. Ideal way is to backup the data rather than copying the whole file
It's suggested that you avoid backing up the whole db file all the time mostly because that's a lot of redundant data traffic, especially if you've only changed one record in a large db. Being able to write per-record updates to the backup system is much more efficient (though of course is not nearly as simple to implement).
I have created Sqlite database in app. when I clear data from settings->applications->manage applications the Sqlite db removed. any suggestions to keep sqlite database as it is.
When you press Clear Data from the Android application manager its supposed to remove everything related to the app such as preferences, databases, caches etc the only thing that gets left is the app so when you re-launch it behaves as if it was just installed.
If you want to allow the user to clear the data but keep the database then there should be an option in the menu that removes the shared preferences but doesn't do anything with the database.
Hope this helps.
Android's SQLite is intented for local app data storage. When you opt to wipe your app's data, this data is wiped (as expected).
If you want to persist DB data, look into external storage (eg. the late Parse.com, or MS's Azure). You'll be making network calls, your local data will still be wiped, and you'll need to have a way to link your app back up with the external data post-local-wipe (eg. logging in) but your external data will survive an app data clear.
The "linking up" part can be mitigated as well depending on your use case, eg. Google Play Games' data services is tied to your Google Play id and will resync after an app wipe.
Why would you want to keep the data when the user wants to clear everything.
It is not suggested you keep the db.
I would suggest you use the sd card to store images/text files with the adequate permission from the user.
I am trying to build an app that will use an SQLite database. My question is once the database is created, will all data still be there once the app is closed, i.e.: the database won't be overwritten when the app is restarted?
You, as a developer are the only one who have access to this database, thus it is only your code which will be allowed to change the state or content of this database.
Yes, the data will remain there.
The data will remain there because of your default create method. There is a status code. You can use SQLScout http://www.idescout.com/ to visualize the table and watch its change step by step.
Yes, data will remain in your application when you close the application. When you run the application the database create in the application.
But yes, if the user uninstalls, the application then user will lose the application. On the other hand, if you want to save the data when the application is uninstalled, then it's better to create the database in SDCard.
Hi all: I need to know if there is any way to make Android persistent data that the user can not delete, because if I use SharedPreferences or databases, it is possible that the user can delete all data from the Android menu, Settings - > applications -> Manage Applications -> "application name" -> Clear Data.
If I keep in the external memory also exist the possibility that the user delete or change memory device.
As always, thank you very much and sorry for my English.
Please check out Swarm's Cloud Data system. It provides a system extremely simple API (very similar to SharedPreferences) for set/get operations. Everything is saved to the cloud, and persists per user account.
This is not possible, your application does not have access to such kind of functionality. The only option you have... is storing data into a remote server.
Store it on your cloud app server.
I agree, If you do not want your users to be able to erase your data, you need to store it outside of the device, and access it via the internet.
You can use your own server for this, alternatively, I have used the Skiller SDK for my multiplayer game and noticed that they provide a simple data storage functionality (which frankly, i didn't use) but it seems like it would answers your needs.
Good luck.
I'm starting with Android development, and I'm trying to do an application that will help users to find events around where they live. Most of those events are static, and therefore could be stored in an internal database. However, there are other events that might have to be added, or existing events that might have to be modified.
My questions are the following:
Which aspects should I take into consideration in order to decide whether should I use an internal database or external database?
If I decide to use an internal database, what are the approaches to update the user database with the new events or whatever changes that might have to be done?
Thanks :)
To extend a bit Kevin's answer I would add that one of the approach could be to use an external database that just return through a webservice a timestamp of the last database update. If this timestamp changes, your local database should be update (maybe by sending only differential changes).
Internal database is an interesting solution if : your app means to be running without connection or the data volume is too important to be requested at each launch.
Without too much detail about your app, I'd keep an internal database that you periodically update from a remote server (which I assume you're calling the "external database").