-1

I was wondering, I"m looking to add update button in my fragment which when user click will check if updates available or not .

I"m looking for solution on How to acess json file from url and check if json value contains new value or not . if key matches to the already specified value then display message you data has been updated and if not then display No updates availaible.

For Example if below is the json file

[
   {
           "updateKey": "1"

      }
]

and if it contains other then 1 then show toast message with updates availaible.

Blueyeti
  • 43
  • 8
  • >> How to access json file from url?? I believe you are trying to say JSON data... if so, you can be **Retrofit** to download the JSON data and convert it into an object. From there, you can use the object to get specific values to determine conditions. I would recommend reading over [Using Retrofit 2.x as REST client](https://www.vogella.com/tutorials/Retrofit/article.html). – Nero Apr 20 '19 at 20:54

1 Answers1

0

To access data from a url you can use retrofit https://square.github.io/retrofit/ when you get e JSON response you can verify if exist key using JSONObject

json = new JSONObject(response);
if (json.has(<key>)) { }

Something similar to this one https://stackoverflow.com/a/43341909/10931055