I want to call a listview adapter from another activies after insert record to sqllite db.
I cant call the adapter.notifyDataSetChanged() method. What is the best way to do it.
public void onClick(View v) {
TextView item_name;
item_name=(TextView) findViewById(R.id.eItemName);
Log.d("Insert: ", "Inserting ..");
db.add_item(new Item(item_name.getText().toString()), getApplicationContext());
// I want to call the method HERE!!!!
finish();
}
Just
After
finish()Current Activity, Calladapter.notifyDataSetChanged()fromonActivityResult()in previous Activity (As I assumes your Listview in this previous Activity).Also start your Current Activity from Previous Activity using
startActivityForResult();Or if you have reference of List Adapter in this Activity, then using that reference call
adapter.notifyDataSetChanged(). (But I think its not a good practice)