I want to add ability for users to backup application database and settings to SD card. Then should be able to restore all data on another device.
How usually these tasks are done? I need recomendations/samples.
I want to add ability for users to backup application database and settings to SD card. Then should be able to restore all data on another device.
How usually these tasks are done? I need recomendations/samples.
With Database you basically have two options.
Case 2
You can use getExternalFilesDir() to store your app data. This will create a folder on SD card with your app name.
How to use standard SQLLiteOpenHelper with custom path read this link. A nice answer at the bottom. Alternatively you can directly open your DB from SD card using openDatabase function. This function just required path to the your database.
Case 1,
if you are copying database to sd card, which basically a regular file copy and in this case do simple file from one path to another. getPath() from SQLiteDatabase will give you path of the database.
Shared Preference With Shared preferences, which support only key values, and how to access shared preferences from a SD card read this link.
Here is a question with many good answers about backing up databases to an SDCard: How do I backup a database file to the SD card on Android?
with the following example: http://mgmblog.com/2009/02/06/export-an-android-sqlite-db-to-an-xml-file-on-the-sd-card/
What is your application all about? I would solve this problem different.
Instead of allowing users to reload their settings from a sd card, create support for user accounts and a server to allow users to synchronize their profiles on log in.