Reputation: 3177
I am tryng to set a alarm by a id of row in the database. Here is my code to set the inent extra but it gives me a errror at putExtra.
public void setReminder(long taskId, Calendar when){
Intent i = new Intent(mContext, OnAlarmReceiver.class);
i.putExtra(helper.getById(id), (long)taskId);
}
Here is my Cursor fetching the Id from my database.
}
public Cursor getById(String id){
String [] args = {id};
return(getReadableDatabase()
.rawQuery("SELECT _id, title, descrip, taskdatetime, type FROM tasks WHERE _id = ?", args));
}
Upvotes: 0
Views: 1477
Reputation: 457
putExtra()
takes the name (a string) and the actual value as inputs.
I doubt helper.getById(id)
in
i.putExtra(helper.getById(id), (long)taskId);
returns a string.
Check that.
public Intent putExtra (String name, Bundle value)
Parameters:
name
-> The name of the extra data, with package prefix &value
-> The Bundle data value.Returns:
Check this link
Hope I was able to help.
Upvotes: 2
Reputation: 1480
You can't put a cursor in an intent. You should read the cursor and make an own datatype of it which you can pass using intents.
i.putExtra(helper.getById(id), (long)taskId);
This makes no sense either. I assume your cursor is the actually data? In that case the helper.getById() should be the second parameter and taskId the first parameter.
Upvotes: 1