If you're using this code, you're probably getting a null value for your object because of one of many reasons (no net connection, wrong site, malformed JSON Object).
Instead of
Log.d("All Products: ", json.toString());
try
if (json!=null)
Log.d("All Products: ", json.toString());
On further review: your
try{...} catch(JSONException ex) {...}
will throw an exception as well, because you're not testing json
for null values in there. So
if (json!=null){
Log.d("All Products: ", json.toString());
try{...} catch(JSONException ex) {...}
}
would be your actual solution.