I am making a Grocery list app.
In my first Activity I have a ListView and in my second activity I can add the new grocery details. I want to show those details in the first Activity's ListView. Now how can I pass data from second Activity to the first Activity in ListView.
In second activity i passed data with fooling code:
            EditText editName = (EditText) findViewById(R.id.txtName);
             EditText editQty=(EditText) findViewById(R.id.txtqty);
             String name= editName.getText().toString();
             String quantity=editQty.getText().toString();
             Intent returnIntent = new Intent();
             returnIntent.putExtra("name",name);
             returnIntent.putExtra("quantity",quantity);
             setResult(RESULT_OK,returnIntent);
             finish();
And in first activity i used that Intent as follows:
           protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 1) {
            if(resultCode == RESULT_OK){
                Bundle b = data.getExtras();
                if ( b!= null ){
                String strName=data.getStringExtra("name");
                String strQty=data.getStringExtra("quantity");
                System.out.println(strName);
                System.out.println(strQty);
                }
            }
            if (resultCode == RESULT_CANCELED) {
                //Write your code if there's no result
            }
        }
Please help me solve this. Thanks in advance.
 
     
     
     
    