Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public void onCreate(SQLiteDatabase db) {
- String create_college_table = "CREATE TABLE " + TableName + " (" +
- " `"+KEY_ID+"` INTEGER PRIMARY KEY AUTOINCREMENT,n" +
- " `"+KEY_DATE+"` DATETIME NOT NULL UNIQUE,n" +
- " `"+KEY_JSON+"` longtext NOT NULLn" +
- ")";
- db.execSQL(create_college_table);
- }
- public void testit() {
- // write the row into the database:
- SQLiteDatabase db = this.getWritableDatabase();
- ContentValues insertValues = new ContentValues();
- // DATE IS FOURTH OF AUGUST 2015
- insertValues.put(KEY_DATE, "04082015");
- insertValues.put(KEY_JSON, "{test}");
- db.insert(
- TableName,
- null,
- insertValues
- );
- // Now read from the database, select the row that was
- // just inserted
- String selectQuery = "SELECT * FROM " + TableName + " " +
- "WHERE " + KEY_JSON + " = '{test}'";
- SQLiteDatabase db_read = this.getWritableDatabase();
- Cursor cursor = db_read.rawQuery(selectQuery, null);
- // Viewing the log the inserted date (04082015) has been
- // outputted as 40082015, this does not occur with dates
- // were the day in the month is ten or larger?!
- Log.e("testMethod", DatabaseUtils.dumpCursorToString(cursor));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement