コード例 #1
0
  private List<PublicFile> getFavoriteDataArrayList() {

    List<PublicFile> list = new ArrayList();
    FavoriteDBOpenHelper db = new FavoriteDBOpenHelper(FavoritesActivity.this);
    list = db.getAllData();
    db.close();
    return list;
  }
コード例 #2
0
    @Override
    protected void onPostExecute(Integer integer) {
      mSwipeRefreshLayout.setRefreshing(false);
      if (integer == 1) {

        FavoriteDBOpenHelper db = new FavoriteDBOpenHelper(context);
        db.deleteAll();
        for (int i = 0; i < files.size(); i++) {
          db.add(files.get(i));
        }
        db.close();

        for (int i = adapter.getItemCount() - 1; i > -1; i--) {
          adapter.removeData(i);
        }

        for (int i = 0; i < files.size(); i++) {
          adapter.addData(i, files.get(i));
        }
      } else {
        Toast.makeText(context, "网络连接异常", Toast.LENGTH_LONG).show();
      }
      super.onPostExecute(integer);
    }