Morning, I would love help with my specific code but if you’re busy any information on using putExtra and retrieveRow would also be a great help.
I’m working on a little android project and i’ve come across the first instance where i need to pass data from one activity to another, unfortunately my knowlede is lacking. I’ve tried looking at the android notepad example but i’m getting pretty mixed up so i’m hoping someone can explain to me using my own code.
Here’s what i’m trying to do.. I have an onItemClick listener for a listview i’ve populated from a sqlite database, when it’s selected i want to pass the row _id along with the contents of another column for that row (the BUDGET_AMOUNT) to another class. So I think i need something like below but as you can see by all the questionmarks i’m really confused about how to implement what i need.
// add an onclicklistener for when an item on the list is pressed
incomeView.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id)
{
Cursor c = ???.retrieveRow(id);
Intent keypadIntent = new Intent(view.getContext(), Keypad.class);
keypadIntent.putExtra(???._ID, id);//put extra needs work
keypadIntent.putExtra(???.BUDGET_AMOUNT, c.getFloat(
c.getColumnIndexOrThrow(???.BUDGET_AMOUNT)));
startActivityForResult (keypadIntent, ???);
}
});
The code above is from my Budget.java class, which i’ve uploaded here. I also have a class called Data.java which extends SQLiteOpenHelper and a class called DatabaseConstants which just has a whole bunch of string variables for categories and queries. Thanks for taking the time to have a look or offer advice.
See if this helps. I think my implementation is slightly different from your, but is for a similar function.