tags:

views:

52

answers:

1

Good day all, First of all, maybe i went about this the wrong way in the first place. Situation is, i have a listview that when an item is clicked, it creates an intent and calls startActivityForResult() to another activity, to be able to edit the entries in the row. and that other activity after editing the required values, returns back to the calling activity, when the user clicks on a save button. The activity then uses the row Id to update the item.My problem now is that, if the user presses the BACK button instead, the application crashes. i have been looking around and see solutions like using Shared Preferences or onSavedInstanceState(), but i don't know where exactly i should be putting the code? Any help as usual, will be greatly appreciated. Thank you.

p.s: when i look at logcat, its gives a NullPointerException for this line in onActivityResult.

     Bundle result = data.getExtras();
+2  A: 

If you are assuming you will have a result on the parent thread if the user quits the activity via Back then that is most likely the issue. Try testing if result is null before attempting to use it.

methodin
Thank you very much! works perfectly! i posted the wrong logcat output, i have corrected it now.
Rexx
@Rexx: If this solved it for you, you can click the check on the left to mark this as the accepted answer
Daenyth
sorry, get so excited, i forget. will do it now
Rexx