import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
+import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.view.View;
public static void deleteAlarm(final Application application, final long time) throws SQLException{
final SQLiteDatabase db = application.alarmOpenHelper.getWritableDatabase();
- db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " = " + time, new String[]{});
+ db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " = " + time, new String[0]);
unsetAlarm(application, time);
}
+ public static long[] getAlarmsByEvent(final Application application, final long eventId) throws SQLException{
+ final SQLiteDatabase db = application.alarmOpenHelper.getWritableDatabase();
+ final Cursor cursor = db.query(AlarmOpenHelper.TABLE, new String[]{AlarmOpenHelper.TIME}, AlarmOpenHelper.EVENT + " = " + eventId, new String[0], null, null, null);
+ if(cursor.moveToFirst()){
+ final long[] ret = new long[cursor.getCount()];
+ for(int i=0;i<ret.length;i++){
+ ret[i]=cursor.getLong(i);
+ cursor.moveToNext();
+ }
+ return ret;
+ }
+ return new long[0];
+ }
+
public static void setAlarm(final Context context, final long time, final long eventId){
final Intent intent = new Intent(context, AlarmReceiverActivity.class);
intent.setAction(Long.toString(time));