You get JSONException
at line int x = price_point.getInt("1364062505");
First of all, look at the source JSON from the URL you are trying to retrieve.
It's structure is:
values: [ {x : timestamp, y : value}, ... ]
Where timestamp is a representaion of the date in millis and value is the price of BTC in USD.
You're trying to getInt("1364062505")
while such key in values
JSON array does not exist.
JSONException
is thrown at getInt(key)
if the key is not found or if the value cannot be converted to an integer (look here).
You need to write int x = price_point.getInt("x")
, or even better - replace your getInt()
to optInt()
and getDouble()
to optDouble()
. In this case you won't get any exceptions, only a zero, if such key in JSONObject
does not exist. Then you should check your values in if (value != 0)
block