// Update our list on a database response public void onDatabaseResponse(JSONObject response) { // Nothing to do if failed request or not a favorites response if (response == null || !response.optBoolean("success")) return; if (!response.optString("action").equals("get_favorites")) return; try { JSONArray resultArray = response.getJSONArray("favorites"); // Build a list of results and update adapter favoriteList.clear(); for (int i = 0; i < resultArray.length(); i++) { favoriteList.add(resultArray.getJSONObject(i)); } favoriteAdapter.notifyDataSetChanged(); } catch (JSONException e) { Log.e(TAG, e.toString(), e); } }