public List<ReminderItem> getAllReminders() { ArrayList<ReminderItem> alarmJobList = new ArrayList<ReminderItem>(); ReminderItem alarmJob = null; SQLiteDatabase db = null; synchronized (this) { db = this.getWritableDatabase(); try { Cursor cursor = db.query(TABLE_NAME, null, null, null, null, null, null); if (cursor != null) { while (cursor.moveToNext()) { alarmJob = createAlarmJobFromCursor(cursor); if (alarmJob != null) { alarmJobList.add(alarmJob); } } cursor.close(); } else { AIOLog.d(AIOConstant.TAG, "[getAlarmJobs]: Cursor is null."); } } catch (SQLiteException e) { e.printStackTrace(); } } return alarmJobList; }
private void createTables(SQLiteDatabase db) { db.beginTransaction(); db.execSQL( "CREATE TABLE IF NOT EXISTS " + ReminderDBHelper.TABLE_NAME + " (" + ReminderDBHelper.JobsColumns._ID + " " + DB_PRIMARY_KEY_TYPE + "," + ReminderDBHelper.JobsColumns.CLASS_NAME + " " + DB_NAME_TYPE + "," + ReminderDBHelper.JobsColumns.CUSTOM_ID + " " + DB_NAME_TYPE + "," + ReminderDBHelper.JobsColumns.TRIGGERTIME + " " + DB_NAME_TYPE + "," + ReminderDBHelper.JobsColumns.INTERVALTIME + " " + DB_NAME_TYPE + "," + ReminderDBHelper.JobsColumns.REPEATCOUNT + " " + DB_INTEGER_TYPE + "," + ReminderDBHelper.JobsColumns.REPEATMODE + " " + DB_INTEGER_TYPE + "," + ReminderDBHelper.JobsColumns.RAWDATA + " " + DB_BYTE_TYPE + ");"); AIOLog.d(AIOConstant.TAG, "DB TABLE(" + ReminderDBHelper.TABLE_NAME + ") Has been created."); db.setTransactionSuccessful(); db.endTransaction(); }
public long addJob( String className, String id, long triggerAtMillis, long intervalMillis, int repeatCount, boolean repeatMode) { long rowId = -1; if (deleteJob(className, id) > 0) { AIOLog.d(AIOConstant.TAG, "addJob: delete a jobs"); } rowId = insert(className, id, triggerAtMillis, intervalMillis, repeatCount, repeatMode); if (rowId < 0) { AIOLog.e(AIOConstant.TAG, "Fail to insert a job for schdule"); return rowId; } else return rowId; }
@Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { AIOLog.d( AIOConstant.TAG, "Upgrading database from version " + oldVersion + " to " + newVersion); upgradeTables(db); }