I have an activity, GridView
, that displays the data from my database. When user selects an Account
it will load up another activity AccountManager
which will contain all details of the selected item from GridView
and allow the user to manage it from there (Modify, Delete and whatnot).
PROBLEM:
When user modifies the Account
the modifications made do not show up in AccountManager
and instead still shows the initial data from GridView
. My guess is it's because the data linked to AccountManager
from GridView
isn't directly linked to the database, rather I use a middle-man for it so the data is in a way static and separate from the database.
QUESTION:
Is there a way to update the data on AccountManager
without having to change my code. If so how do I do this, if not what method would allow me to get the data on AccountManager
to be linked to the data in my database so any modifications will reflect on AccountManager
immediately after modification.
How I pass data from GridView
to AccountManager
grid.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
try {
SQLiteCursor cr = (SQLiteCursor) parent.getItemAtPosition(position);
String name = cr.getString(cr.getColumnIndex(DatabaseHelper.colName));
int amount = cr.getInt(cr.getColumnIndex(DatabaseHelper.colAmount));
String purpose = cr.getString(cr.getColumnIndex(DatabaseHelper.colPurpose));
String Terms = cr.getString(cr.getColumnIndex(DatabaseHelper.colTermsClass));
String Status = cr.getString(cr.getColumnIndex(DatabaseHelper.colStatClass));
String date = cr.getString(cr.getColumnIndex(DatabaseHelper.colDate));
String editdate = cr.getString(cr.getColumnIndex(DatabaseHelper.colEditDate));
Account acc = new Account(name, amount, purpose, db.GetTermsID(Terms),date,editdate,db.GetStatID(Status));
acc.SetID((int) id);
Intent myIntent = new Intent(AccountManager.this, AccountDetails.class);
myIntent.putExtra("AccountObject", acc);
startActivityForResult(myIntent, 0);
}
}
}
How I retrieve the data from GridView
in AccountManager
final Account Acc = (Account) getIntent().getSerializableExtra("AccountObject");
Aucun commentaire:
Enregistrer un commentaire