How can I make Android application data persistent?
I am new to Android development and am creating a "ToDoList" app in Android.
I used a SQLlite database to save the list in a database table, and it saved data perfectly.
I don't have an Android phone, so I can check my application only using an emulator.
After saving tasks in the database, if a user restarts the phone then will my task list in database be deleted or not? If it will be 开发者_如何学Cdeleted then how can I make the data in the table persistent?
The table definitely stays if the user simply reboots the phone. Off the top of my head, I think the only way to get rid of the table completely is to either:
- Delete it (programmatically or via the sql command line)
- Uninstall the application
Simply upgrading your application to a new version will not delete your existing tables (so long as you use the same keystore when making the APK.)
-- Dan
For saving persistent application data Android offers various options.
A comparison between SQLite and SharedPreferences for storing persistent data.
Considering you are developing a ToDoList app for Android, I would recommend sticking to SQLite.
精彩评论