-1

I have a online json file with arrays with categories as follows:

[{"id":1,"name":"Moda","howmuch":42}, (...)]

And there's 11 of these categories. Now what I need is to make that the app will download these arrays and put them to the Android app, so user can choose a category. It cannot be hardcoded to strings.xml.

4
  • have you search any tutorials or not? Commented Jun 20, 2017 at 13:14
  • Yes, I've searched for tutorials but there's nothing I could use for my project. Commented Jun 20, 2017 at 13:15
  • this link might helpful to you androidbegin.com/tutorial/… Commented Jun 20, 2017 at 13:17
  • Please check my code , surely it will help you and for further you can just learn about parsing data from server concepts. Thanks. Commented Jun 20, 2017 at 13:33

2 Answers 2

0

I think you're searching for this, On app start you save your this arrays into shared Preferences or you can save to your Sqlite database

Sign up to request clarification or add additional context in comments.

Comments

0

You can do like this :

String result = "your result here";
        try {
            JSONArray data = new JSONArray(result);
            if(data.length() > 0){
               for (int i =0; i < data.length(); i++){
                   String id = data.getJSONObject(i).getString("id");
                   String name = data.getJSONObject(i).getString("name");
                   String howmuch = data.getJSONObject(i).getString("howmuch");
               }
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.