Add, show and remove alarms
[unical.git] / src / ro / ieval / unical / Utils.java
index 895c9464d30069dc8150934c5436b30f7f2d1d3d..3b53b479a90cce7964136bcbaeb759055f1a6f5c 100644 (file)
@@ -45,18 +45,19 @@ final class Utils {
                unsetAlarm(application, time);
        }
 
-       public static long[] getAlarmsByEvent(final Application application, final long eventId) throws SQLException{
+       public static Long[] getAlarmsByEvent(final Application application, final long eventId) throws SQLException{
                final SQLiteDatabase db = application.alarmOpenHelper.getWritableDatabase();
+               db.delete(AlarmOpenHelper.TABLE, AlarmOpenHelper.TIME + " < " + System.currentTimeMillis(), new String[0]);
                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()];
+                       final Long[] ret = new Long[cursor.getCount()];
                        for(int i=0;i<ret.length;i++){
-                               ret[i]=cursor.getLong(i);
+                               ret[i]=cursor.getLong(0);
                                cursor.moveToNext();
                        }
                        return ret;
                }
-               return new long[0];
+               return new Long[0];
        }
 
        public static void setAlarm(final Context context, final long time, final long eventId){
This page took 0.010433 seconds and 4 git commands to generate.