drhouse87
drhouse87

Reputation: 25

Save SQLite database

In my application, I'm using a database to store some data, but if I close my app, my database will be deleted too. So I want to know if there is any mean to save my database and re-use it for the next launch of my app.

I use for the moment public DatabaseHandler(Context context) { super(context, DATABASE_NAME, null, DATABASE_VERSION); } in order to create my database.

Thanks for your help

Upvotes: 0

Views: 4986

Answers (3)

Nav
Nav

Reputation: 10412

use sqliteopenhelper

check this link http://thenewboston.org/list.php?cat=6

It contains tutorials with code included which you can easily understand for the purpose you want to accomplish

Upvotes: 0

Anup Purushu
Anup Purushu

Reputation: 11

To create a database in your Android application you usually subclass SQLiteOpenHelper. In the constructor of your subclass you call the super() method of SQLiteOpenHelper, specifying the database name and the current database version.
In this class you need to override the onCreate() method.

Refer: http://www.vogella.de/articles/AndroidSQLite/article.html#sqliteoverview

Upvotes: 1

waqaslam
waqaslam

Reputation: 68177

If you are creating database using SQLiteOpenHelper it won't be deleted unless you do it purposely. They are used for persistent memory storage, therefore Android framework doesn't delete it itself unless user clears app data and cache from Application Settings.

Upvotes: 3

Related Questions