let my function work always when my app is off : actually i am developing an alarm so i need to retrieve times from database
the code explain how i iterate my database and retrieve hour and minutes and then set it in calendar
how can i let that function working always and always looping in my database  to compare with current time  and then ring?
what about requestcode ? i read that its important and i should take id of row in my database and put it requestcode !!  

      private void ringalarms(){
            Cursor data = myDB.getListContents();
            int  hr,mt = 0;
            alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
            final Calendar calendar = Calendar.getInstance();
            final Intent myIntent = new Intent(this.context, Alarm_Receiver.class);
    
    
            data.moveToFirst();
            while (!data.isAfterLast()) {
                hr=Integer.parseInt(data.getString(0));
                mt=Integer.parseInt(data.getString(1));
    
                calendar.set(Calendar.HOUR_OF_DAY, hr);
                calendar.set(Calendar.MINUTE, mt);
    
    
                
                myIntent.putExtra("extra", "yes");
                //myIntent.putExtra("id", i);
    
    
                pending_intent = PendingIntent.getBroadcast(Add_Alarm.this, 0, myIntent, PendingIntent.FLAG_UPDATE_CURRENT);
    
    
                alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),AlarmManager.INTERVAL_DAY, pending_intent);
    
    
    
    
                data.moveToNext();
            }
    
        }


> Blockquote

  

      public Cursor getListContents(){
            SQLiteDatabase db = this.getWritableDatabase();
            Cursor data = db.rawQuery("SELECT Hour, Minutes FROM " + TABLE_NAME, null);
            return data;
        }

