multiple alarms SQLite

I'm new on android programming and i'm working on android application and i'm stuck in creating multiple alarms. my code only fires the last alarm and ignore the previous ones the dates are stored in a database (SQlite) that the user specifies

this is my reminder manager class

public class ReminderManager {

    private Context mContext; 
    private AlarmManager mAlarmManager;

    public Appointments_ReminderManager(Context context) {
        mContext = context; 
        mAlarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE);

    public void setReminder(Long reminderId, Calendar when) {

        Intent i = new Intent(mContext, Appointments_OnAlarmReceiver.class);
        i.putExtra(RemindersDbAdapter.KEY_ROWID_APPOIN, (long)reminderId); 

        PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_ONE_SHOT); 

        mAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), pi);

and this is the receiver class

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class OnAlarmReceiver extends BroadcastReceiver {

    private static final String TAG = ComponentInfo.class.getCanonicalName(); 

    public void onReceive(Context context, Intent intent) {
        Log.d(TAG, "Received wake up from alarm manager.");

        long rowid = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID_APPOIN);


        Intent i = new Intent(context, ReminderService.class); 
        i.putExtra(RemindersDbAdapter.KEY_ROWID_APPOIN, rowid);  


can someone please help me modifying my code to fire multiple alarms specified by the user that is stored in a database.


Luckily the answer is pretty simple. Your code is:

PendingIntent pi = PendingIntent.getBroadcast(mContext, 0, i, PendingIntent.FLAG_ONE_SHOT);

The second parameter is the request_code is like an id for the PendingIntent and since you're always override the previous PendingIntent. So what you have to do is to set a unique request code for every alarm you need. In your case you can use the reminderId, which is, I guess the DB row id. And because this is a unique ID for every Alarm it perfectly fits.

PendingIntent pi = PendingIntent.getBroadcast(mContext, reminderId, i, PendingIntent.FLAG_ONE_SHOT);

Need Your Help

Error using Container Class

c# class

The Class that is using the container is throwing an error on AmountList and PGRow that says AmountList is inaccessible due to its protection level

a little bit of python help

python google-app-engine

i need a little help here, since i am new to python, i am trying to do a nice app that can tell me if my website is down or not, then send it to twitter.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.