forked from jeremyhaberman/restful-android
/
ProfileData.java
37 lines (29 loc) · 1.09 KB
/
ProfileData.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package mn.aug.restfulandroid.provider;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import static android.provider.BaseColumns._ID;
import static mn.aug.restfulandroid.provider.ProfileConstants.NAME;
import static mn.aug.restfulandroid.provider.ProfileConstants.TABLE_NAME;
class ProfileData extends SQLiteOpenHelper {
private static final String DATABASE_NAME = "profiles.db";
private static final int DATABASE_VERSION = 1;
/**
* Create a helper object for the Profile database
*/
ProfileData(Context ctx) {
super(ctx, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " ("
+ _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ NAME + " TEXT);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion,
int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}