Import data from JSON or XML feed and create a List in Android
<p>I am trying to make an Android class that creates a List of other apps, for later display, until now I have the following code for creating the List (taken from a google example):</p>

<pre><code>public final class AppList {

public static List&lt;App&gt; list;

public static List&lt;App&gt; setupApp() {
    list.add(buildAppInfo(
            "Browsers",
            "chrome",
            "description",
            "Google Inc.",
            "com.android.chrome",
            "http://...",
            "http://..."
    ));
    list.add(buildAppInfo(
            "Browsers",
            "Firefox",
            "description",
            "Mozilla",
            "com.mozilla.firefox",
            "http://...",
            "http://..."
    ));
    [An so on...]

    return list;
}

private static App buildAppInfo(String category,
                                    String title,
                                    String description,
                                    String developer,
                                    String packageName,
                                    String iconImageUrl,
                                    String bgImageUrl) {
    App app = new App();
    app.setId(App.getCount());
    App.incCount();
    app.setTitle(title);
    app.setDescription(description);
    app.setDeveloper(developer);
    app.setCategory(category);
    app.setIconImageUrl(iconImageUrl);
    app.setBackgroundImageUrl(bgImageUrl);
    app.setPackageName(packageName);
    return app;
    }
}
//From here everything is handled in other activity
</code></pre>

<p>I will like instead to load the details dynamically from a web server that I can setup to feed either a JSONArray or an XML and then put that data on the list. For what I was reading I could use Volley, but I am not very experienced in Volley or Java in general (I am just learning in the road) so I don't have to much idea on how to proceed.</p>

<p>From the google developers site I found an <a href="https://developer.android.com/training/volley/request.html#request-json" rel="nofollow noreferrer">example</a>. I was thinking on add something like this:</p>

<pre><code>public final class AppList {

public static List&lt;App&gt; list;

public static List&lt;App&gt; setupApp() {
    /*Json Request*/
    String url = "https://json_url/";
    JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( Request.Method.GET, url, null,
            new Response.Listener&lt;JSONObject&gt;() {
                @Override
                public void onResponse(JSONObject response) {
                    list.add(response);//ADD ITEMS TO LIST HERE
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }
            });

    return list;
}

private static App buildAppInfo(String category,
                                    String title,
                                    String description,
                                    String developer,
                                    String packageName,
                                    String iconImageUrl,
                                    String bgImageUrl) {
    App app = new App();
    app.setId(App.getCount());
    App.incCount();
    app.setTitle(title);
    app.setDescription(description);
    app.setDeveloper(developer);
    app.setCategory(category);
    app.setIconImageUrl(iconImageUrl);
    app.setBackgroundImageUrl(bgImageUrl);
    app.setPackageName(packageName);
    return app;
    }
}
</code></pre>

<p>The data received from the server feed should be something like:</p>

<pre><code>buildAppInfo(
            "Browsers",
            "Firefox",
            "description",
            "Mozilla",
            "com.mozilla.firefox",
            "http://...",
            "http://..."
    )
buildAppInfo(
            "Browsers",
            "Firefox",
            "description",
            "Mozilla",
            "com.mozilla.firefox",
            "http://...",
            "http://..."
    )
[...]
//BUT IN JSON FORMAT
</code></pre>

<p>My entire approach obviously doesn't work. Can someone please help me to achieve what I need? Thank you.</p>