-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
110 additions
and
2 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
app/src/main/java/com/aziflaj/todolist/db/TaskContract.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.aziflaj.todolist.db; | ||
|
||
import android.provider.BaseColumns; | ||
|
||
public class TaskContract { | ||
public static final String DB_NAME = "com.aziflaj.todolist.db"; | ||
public static final int DB_VERSION = 1; | ||
|
||
public class TaskEntry implements BaseColumns { | ||
public static final String TABLE = "tasks"; | ||
|
||
public static final String COL_TASK_TITLE = "title"; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/main/java/com/aziflaj/todolist/db/TaskDbHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.aziflaj.todolist.db; | ||
|
||
import android.content.Context; | ||
import android.database.sqlite.SQLiteDatabase; | ||
import android.database.sqlite.SQLiteOpenHelper; | ||
|
||
public class TaskDbHelper extends SQLiteOpenHelper { | ||
|
||
public TaskDbHelper(Context context) { | ||
super(context, TaskContract.DB_NAME, null, TaskContract.DB_VERSION); | ||
} | ||
|
||
@Override | ||
public void onCreate(SQLiteDatabase db) { | ||
String createTable = "CREATE TABLE " + TaskContract.TaskEntry.TABLE + " ( " + | ||
TaskContract.TaskEntry._ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " + | ||
TaskContract.TaskEntry.COL_TASK_TITLE + " TEXT NOT NULL);"; | ||
|
||
db.execSQL(createTable); | ||
} | ||
|
||
@Override | ||
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { | ||
db.execSQL("DROP TABLE IF EXISTS " + TaskContract.TaskEntry.TABLE); | ||
onCreate(db); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters