dimanche 21 décembre 2014

What if i change the SQLite DB name?

I have changed the data format for my app, so all previously stored data in SQLite DB with DB_NAME_1 is not useful. I want to delete previous data and store new data with a new DB_NAME_2.


I used SQLiteOpenHelper class for creating DB in my code and ContentProvider class to access tables.



public class DBHelper extends SQLiteOpenHelper {

public DBHelper(Context context) {
super(context, DB_NAME, null, VERSION);
}

@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table " + TABLE_BOOK + " ("+TABLE_BOOK_ID+" integer primary key autoincrement, "
+ TABLE_BOOK_TOPIC + " integer, " + TABLE_BOOK_TIME+" long, "
+ TABLE_BOOK_PAGE_DATA+" text, " + TABLE_BOOK_PAGE_SCORE + " integer);");
}



  1. How can i do that?

  2. If i simply change the DB_NAME_1 to DB_NAME_2, it will create a new file with DB_NAME_2. How can i delete the previous file with DB_NAME_1.


Aucun commentaire:

Enregistrer un commentaire