Skip to content Skip to sidebar Skip to footer

Android Error Converting Result Java.lang.nullpointerexception

I am trying to create a simple login and registration activity in Android. I am getting the errors Error converting result java.lang.nullpointerexception,error parsing data or

Solution 1:

That might be because the key not even exist, do this before calling json.getString("key"); method:

JSONObject json = yourJSON;
if(json != null && !json.isNull(KEY_SUCCESS)){
   //Wahetever you needString value = json.getString(KEY_SUCCESS);
   if(value != null && value.length > 0){
       //You will fall here only if there's a value...
   }
}

Notice that you first need to make sure that the key actually exist, otherway it could throw a JSONException...

Hope this helps...

Regards!

Post a Comment for "Android Error Converting Result Java.lang.nullpointerexception"