mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-01-06 03:26:45 +01:00
create a database for storing notes
This commit is contained in:
parent
e2c1573059
commit
ade79264c7
@ -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) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user