I have a JSON file with just one Array as in this example (as you see this array doesn't have a name):
["Cream","Cheese","Milk","Powder Milk","Blue Cheese","Gouda Cheese"]
How can I just get this array into an array or an arraylist in my Android Studio?
Thank you so much in advance!
Here is a function that I am creating to get this array yet I can't complete it I am still a noob with handling json files.
public void getProducts() {
JsonArrayRequest myresponseArray = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
try {
for(int i = 0 ; i < response.length();i++){
JSONArray responseArray = response.getJSONArray(i);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
}
Now I want to add this "responseArray" into my products array list that I created on the MainActivity
ArrayList<String> products = new ArrayList<String>();