The value of the string is null


I have a ListView with each row containing a TextView. On user click, I'm getting the value of the TextView and storing it in a String variable, and the user is navigated to another activity where he / she needs to input some data on said TextView. In order to not lose the information state of the first activity, I had to use startActivityForResult() and later get the information from the second activity with the method onActivityResult().

The problem is this: I need to compare a value with that of the TextView in question, however the String variable which supposedly contains the TextView's value is null.

Before starting up the second activity I toasted the String value and it returned the correct string, however not in the onActivityResult(), where it returns null.

Why is this happening? Isn't the Intent I used suppose to retain all information of the opened activity?

ListView's onItemClick

        public void onItemClick(AdapterView<?> listView, View itemView, int itemPosition, long itemID)

            clickedError = ((TextView)itemView).getText().toString();
            String errorIDQuery = "SELECT _id FROM " + TABLE_ERROR + " WHERE error_description LIKE '" + clickedError + "';";

                Cursor getErrorID = db.rawQuery(errorIDQuery, null);
                errorID = getErrorID.getInt(0);

            Intent intent = new Intent(Repair.this, Material.class);
            intent.putStringArrayListExtra("materialList", materialList);
            startActivityForResult(intent, 1);
            Toast.makeText(getApplicationContext(), clickedError, Toast.LENGTH_LONG).show();


protected void onActivityResult(int requestCode, int resultCode, Intent data)
    if(resultCode == RESULT_OK)
        HashMap <String, String> materialDetails = (HashMap <String, String>)data.getSerializableExtra("map");
        Set<?> set = materialDetails.entrySet();
        Iterator<?> i = set.iterator();

        ArrayList<String> materialNames = new ArrayList<String>();
        ArrayList<String> materialAmounts = new ArrayList<String>();

            Map.Entry me = (Map.Entry);

        while (i.hasNext());

        for(Error e : errorList)
            // ----- COMPARING THE VALUES -----
            // here clickedError is null
                for(int j = 0; j < materialNames.size(); j++)
                    MaterialClass mc = new MaterialClass();
                if (e.materialList.size() != 0)
                    e.checked = true;
                    e.checked = false;

Make your String value as static so that it will retain its value. or you can use shared preference to save value and use it later.