-1

I want to get data from another activity through OnActivityResult,put the data to sqllite and print to listview. What must I put to OnActivityResult method?

I really seen many examples but I don't understand them and now. Thanks for answers.

Dhanuka
  • 2,826
  • 5
  • 27
  • 38

2 Answers2

0
  1. put the data to sqlite.
  2. notifying to listview's adapter (corsur adapter)

that's all.

jihoon kim
  • 1,270
  • 1
  • 16
  • 22
0

Let assume you have two activity A , B and you want to pass data from B to A, where you start activity B from A. Now to get result from B you should start Activity B with the method startactivityforresult

static final int ACITIVITY_B_ID = 1;
startActivityForResult(new Intent(this, B.class), ACITIVITY_B_ID);

from activity A. Now from activity B you should set result like following

Intent resultIntent = new Intent();
resultIntent.putExtra("key_of_str", "str_to_send");
setResult(Activity.RESULT_OK, resultIntent);
finish();

Now onActivityResult of A should be called with that intent.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    // Check which request we're responding to
    if (requestCode == ACITIVITY_B_ID) {
        // Make sure the request was successful
        if (resultCode == RESULT_OK) {
           String data = intent.getStringExtra("key_of_str");
        }
    }
}

You may look into this answer Sending data back to the Main Activity in android and this one for details http://developer.android.com/training/basics/intents/result.html

Community
  • 1
  • 1
sabbir
  • 438
  • 3
  • 11