Skip to content

Instantly share code, notes, and snippets.

@livando
Created October 6, 2010 09:57
Show Gist options
  • Save livando/613107 to your computer and use it in GitHub Desktop.
Save livando/613107 to your computer and use it in GitHub Desktop.
class Tasks extends SQLiteOpenHelper implements DB {
private static final String DATABASE_NAME = "task.db";
private static final int DATABASE_VERSION = 1;
public Tasks(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + TABLE_NAME + " (" + _ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + DUE_DATE + " INTEGER," + COMPLETE + " INTEGER, " + TASK + " TEXT NOT NULL);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
onCreate(db);
}
}
interface DB {
final String TABLE_NAME = "task";
final String COMPLETE = "complete";
final String TASK = "task";
final String DUE_DATE = "dueDate";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment