-
-
Save wirasetiawan29/6a865c7d59e175d6e4df to your computer and use it in GitHub Desktop.
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
/** | |
* Created by wira on 1/4/16. | |
*/ | |
import android.content.Context; | |
import android.database.sqlite.SQLiteDatabase; | |
import android.database.sqlite.SQLiteOpenHelper; | |
import android.util.Log; | |
public class TaskDBHelper extends SQLiteOpenHelper { | |
public TaskDBHelper(Context context) { | |
super(context, TaskContract.DB_NAME, null, TaskContract.DB_VERSION); | |
} | |
@Override | |
public void onCreate(SQLiteDatabase sqlDB) { | |
String sqlQuery = | |
String.format("CREATE TABLE %s (" + | |
"_id INTEGER PRIMARY KEY AUTOINCREMENT, " + | |
"%s TEXT)", TaskContract.TABLE, | |
TaskContract.Columns.TASK); | |
Log.d("TaskDBHelper","Query to form table: "+sqlQuery); | |
sqlDB.execSQL(sqlQuery); | |
} | |
@Override | |
public void onUpgrade(SQLiteDatabase sqlDB, int i, int i2) { | |
sqlDB.execSQL("DROP TABLE IF EXISTS "+TaskContract.TABLE); | |
onCreate(sqlDB); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment