equal
deleted
inserted
replaced
|
1 package com.beem.project.beem.provider; |
|
2 |
|
3 import android.content.Context; |
|
4 import android.database.sqlite.SQLiteDatabase; |
|
5 import android.database.sqlite.SQLiteOpenHelper; |
|
6 import android.util.Log; |
|
7 |
|
8 public class BeemDatabaseHelper extends SQLiteOpenHelper { |
|
9 |
|
10 private String tag; |
|
11 private String tableName; |
|
12 private String creationQuery; |
|
13 |
|
14 public BeemDatabaseHelper(Context context, String tag, String tableName, String creationQuery) { |
|
15 super(context, Beem.DB_NAME, null, Beem.DB_VERSION); |
|
16 |
|
17 this.tag = tag; |
|
18 this.tableName = tableName; |
|
19 this.creationQuery = creationQuery; |
|
20 } |
|
21 |
|
22 @Override |
|
23 public void onCreate(SQLiteDatabase db) { |
|
24 db.execSQL(this.creationQuery); |
|
25 } |
|
26 |
|
27 @Override |
|
28 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { |
|
29 Log.w(this.tag, "Upgrading database from version " + oldVersion + " to " |
|
30 + newVersion + ", which will destroy all old data"); |
|
31 db.execSQL("DROP TABLE IF EXISTS " + this.tableName + ";"); |
|
32 onCreate(db); |
|
33 } |
|
34 } |