Чтобы получить доступ к данным в Деятельности A, используйте onActivityResult () в Деятельности A следующим образом:
@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();
}
}
И помните, что вы можете использовать этот метод с методом intent с вызовом startActivityForResult()
с намерением Вот и все, что вы должны сделать
Если есть какая-то путаница, тогда вы можете спросить
РЕДАКТИРОВАТЬ: Этот код поможет в получении данных
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();
}