Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public List<User> getUser() {
- List<User> userList = new ArrayList<>();
- Cursor cursor = database.query(MySQLiteHelper.TABLE_USER,
- allColumns, null, null, null, null, null);
- if (cursor.getCount() > 0) {
- cursor.moveToFirst();
- if (cursor.moveToFirst()) {
- while (!cursor.isAfterLast()) {
- User user = cursorToUser(cursor);
- userList.add(user);
- cursor.moveToNext();
- }
- }
- // make sure to close the cursor
- cursor.close();
- }
- return userList;
- }
- public int getUserCount() {
- String countQuery = "SELECT " + MySQLiteHelper.COLUMN_EMAIL + " FROM " + MySQLiteHelper.TABLE_USER;
- Cursor cursor = database.rawQuery(countQuery, null);
- int count = cursor.getCount();
- cursor.close();
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment