greyhat49

attempt to reopen an already-closed object: sqlite

Dec 6th, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. public List<User> getUser() {
  2.         List<User> userList = new ArrayList<>();
  3.  
  4.         Cursor cursor = database.query(MySQLiteHelper.TABLE_USER,
  5.                 allColumns, null, null, null, null, null);
  6.  
  7.         if (cursor.getCount() > 0) {
  8.             cursor.moveToFirst();
  9.             if (cursor.moveToFirst()) {
  10.                 while (!cursor.isAfterLast()) {
  11.                     User user = cursorToUser(cursor);
  12.                     userList.add(user);
  13.                     cursor.moveToNext();
  14.                 }
  15.             }
  16.             // make sure to close the cursor
  17.             cursor.close();
  18.         }
  19.         return userList;
  20.     }
  21.  
  22.     public int getUserCount() {
  23.         String countQuery = "SELECT  " + MySQLiteHelper.COLUMN_EMAIL + " FROM " + MySQLiteHelper.TABLE_USER;
  24.         Cursor cursor = database.rawQuery(countQuery, null);
  25.  
  26.         int count = cursor.getCount();
  27.         cursor.close();
  28.  
  29.         return count;
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment