create a database for storing notes

This commit is contained in:
tibbi 2016-09-25 20:25:40 +02:00
parent e2c1573059
commit ade79264c7
1 changed files with 38 additions and 0 deletions

View File

@ -0,0 +1,38 @@
package com.simplemobiletools.notes.databases;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class DBHelper extends SQLiteOpenHelper {
private static final String DB_NAME = "notes.db";
private static final int DB_VERSION = 1;
private static final String TABLE = "notes";
private static final String COL_ID = "id";
private static final String COL_NAME = "name";
private static final String COL_TEXT = "text";
public static DBHelper newInstance(Context context) {
return new DBHelper(context);
}
private DBHelper(Context context) {
super(context, DB_NAME, null, DB_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE + "(" +
COL_ID + " INTEGER PRIMARY KEY, " +
COL_NAME + " TEXT, " +
COL_TEXT + " TEXT" +
")"
);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}