When I am trying to access catagory array after this code it gives me nullpointerexception. I am returning this array to other class. So it also produce nullpointerexception.
JsonObjectRequest req = new JsonObjectRequest(url, new JSONObject(),
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
// handle response
try {
JSONArray jarray=(JSONArray)response.get(item);
catagory=new String[jarray.length()][2];
//catagory_name=new String[jarray.length()];
for(int i=0;i<jarray.length();i++){
JSONObject jobj = (JSONObject) jarray
.get(i);
catagory[i][1]=jobj.getString(sectionurl);
catagory[i][0]=jobj.getString(name);
}
}
catch (JSONException je){
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// handle error
}
})
String str=catagory[0][0];//AT THIS LINE AN EXCEPTION IS THROWN