· 10 years ago · Aug 29, 2016, 05:54 PM
1package dp.tasker;
2
3import android.content.Context;
4import android.database.sqlite.SQLiteDatabase;
5import android.database.sqlite.SQLiteOpenHelper;
6import android.util.Log;
7
8/**
9 * Created by user on 8/29/2016.
10 */
11public class database extends SQLiteOpenHelper {
12 public static final String TABLE_reg = "registration";
13 public static final String COLUMN_ID = "_id";
14 public static final String COLUMN_name = "_name";
15 public static final String COLUMN_email = "_email";
16 public static final String COLUMN_password = "_password";
17
18 private static final String DATABASE_NAME = "registration_db.db";
19 private static final int DATABASE_VERSION = 1;
20
21 private static final String DATABASE_CREATE = "CREATE TABLE `TABLE_reg` ( `COLUMN_ID` INTEGER NOT NULL, `COLUMN_name` TEXT NOT NULL, `COLUMN_email` TEXT NOT NULL, `COLUMN_password` TEXT NOT NULL, PRIMARY KEY(COLUMN_ID) );";
22
23
24 public database(Context context) {
25 super(context, DATABASE_NAME, null, DATABASE_VERSION);
26 }
27
28 @Override
29 public void onCreate(SQLiteDatabase database) {
30 database.execSQL(DATABASE_CREATE);
31 }
32
33 @Override
34 public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
35 Log.w(database.class.getName(),
36 "Upgrading database from version " + oldVersion + " to "
37 + newVersion + ", which will destroy all old data");
38 db.execSQL("DROP TABLE IF EXISTS " + TABLE_reg);
39 onCreate(db);
40 }
41
42}