我在开发的Android应用程序中有一个GridView
,我从API获取这个GridView
的数据并将API数据存储到本地数据库中,然后将其显示在GridView
。我的问题是,当我第一次显示数据时,它的确定,但是当我重新启动应用程序的GridView
时,会发生重复数据。stop当从api显示数据到gridview时重复数据android
JsonArrayRequest movieReq = new JsonArrayRequest(url, new Response.Listener<JSONArray>() {
@Override
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hidePDialog();
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
Movie movie = new Movie();
movie.setTitle(obj.getString("title"));
movie.setThumbnailUrl(obj.getString("image"));
// adding movie to movies array
movieList.add(movie);
} catch (JSONException e) {
e.printStackTrace();
}
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
});
如何在我的GridView
中阻止此问题?