From e48e7f05d4ea0dfa0cb230ae53edc6341f985f41 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 19 Aug 2013 15:33:26 +0300 Subject: [PATCH] Add untested getAlarmsByEvent function --- src/ro/ieval/unical/Utils.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/ro/ieval/unical/Utils.java b/src/ro/ieval/unical/Utils.java index e842347..895c946 100644 --- a/src/ro/ieval/unical/Utils.java +++ b/src/ro/ieval/unical/Utils.java @@ -8,6 +8,7 @@ import android.app.PendingIntent; 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; @@ -40,10 +41,24 @@ final class Utils { 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