To access the data in Activity A, use the onActivityResult() in Activity A in the following way:
@Override protected void onActivityResult(int requestCode, int resultCode, ntent intent) { super.onActivityResult(requestCode, resultCode, intent); if (requestCode == PICK_CONTACT_REQUEST && resultCode == 10) { pos = intent.getIntExtra("doc_id", 1); mDbHelper.open(); /* Write the database accessing code and whatever you want to do on returning back from Activity B here. */ mDbHelper.close(); } }
And also remember that you can use this method with the intent method with calling startActivityForResult() with intent That's it, what you have to do
If there is any confusion then you can ask
EDIT: This code will help in fetching the data
public class FirstActivity extends Activity { AnyDBAdapter mDbHelper = new AnyDBAdapter(this); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); mDbHelper.open(); Cursor foemiCursor = mDbHelper.fetchAll();/*fetchAll() is which you need to create in AnyDBAdapter class showing query for fetching the database */ startManagingCursor(foemiCursor); /*Now the query will get executed and you need to access just vales from it, here you write code for it*/ foemiCursor.close(); mDbHelper.close(); }