List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.akhbulatov.wordkeeper.ui.fragment.CategoryListFragment.java
private void deleteCategory() { // First, deletes all words that are in the deleted category Cursor cursor = mWordDbAdapter.getRecordsByCategory(getName()); WordAdapter wordAdapter = new WordAdapter(cursor); while (!cursor.isAfterLast()) { long id = wordAdapter.getItemId(cursor.getPosition()); mWordDbAdapter.delete(new Word(id)); cursor.moveToNext();// w w w.j a va 2s . c o m } mCategoryDbAdapter.delete(new Category(mSelectedItemId)); getLoaderManager().restartLoader(LOADER_ID, null, this); }
From source file:com.example.cmput301.model.DatabaseManager.java
/** * Get the local task list./*ww w. j a va 2 s.c o m*/ * * @return A list of tasks in the local table of the database * @throws JSONException */ public ArrayList<Task> getLocalTaskList() { try { ArrayList<Task> out = new ArrayList<Task>(); Cursor c = db.rawQuery("SELECT * FROM " + StringRes.LOCAL_TASK_TABLE_NAME, new String[] {}); if (c.moveToFirst()) { while (c.isAfterLast() == false) { JSONObject obj = toJsonTask(c.getString(c.getColumnIndex(StringRes.COL_CONTENT))); out.add(toTask(obj)); c.moveToNext(); } return out; } } catch (JSONException e) { e.printStackTrace(); } return null; }
From source file:com.chalmers.feedlr.service.DataService.java
/** * Populates application database ITEM table with the most recent tweets * from all the users in the specified feed through {@link * #updateTweetsByUser(final String userID, final Feed feed) * updateTweetsByUser}./* w w w . j a v a 2 s. c o m*/ * * @param feed * the feed to be updated */ public void updateFeedTwitterItems(final Feed feed) { runAsync(new Runnable() { @Override public void run() { final List<User> twitterUsersInFeed = new ArrayList<User>(); Cursor c = db.getUsers(feed, "twitter"); c.moveToFirst(); while (!c.isAfterLast()) { User u = new User(c.getString(c.getColumnIndex(DatabaseHelper.USER_COLUMN_USERID)), c.getString(c.getColumnIndex(DatabaseHelper.USER_COLUMN_USERNAME))); twitterUsersInFeed.add(u); c.moveToNext(); } for (User u : twitterUsersInFeed) { updateTweetsByUser(u.getId(), feed); } } }); }
From source file:com.example.cmput301.model.DatabaseManager.java
/** * Get the remote task list.// w w w . ja v a 2 s . co m * * @return A list of tasks in the remote table of the database * @throws JSONException */ //fixed public ArrayList<Task> getRemoteTaskList() { try { Log.d("refresh", "STARTING REMOTE TASK LIST"); ArrayList<Task> out = new ArrayList<Task>(); Cursor c = db.rawQuery("SELECT * FROM " + StringRes.REMOTE_TASK_TABLE_NAME, new String[] {}); if (c.moveToFirst()) { while (c.isAfterLast() == false) { JSONObject obj = toJsonTask(c.getString(c.getColumnIndex(StringRes.COL_CONTENT))); out.add(toTask(obj)); c.moveToNext(); } } Log.d("refresh", "sizeof remotetasklist = " + out.size()); return out; } catch (JSONException e) { e.printStackTrace(); } return null; }
From source file:mobisocial.musubi.BootstrapActivity.java
private void ensureRingtone() { SharedPreferences settings = getSharedPreferences(SettingsActivity.PREFS_NAME, 0); if (settings.getString("ringtone", null) != null) { return;/* www . java 2s. c o m*/ } RingtoneManager ringtoneManager = new RingtoneManager(this); ringtoneManager.setType(RingtoneManager.TYPE_NOTIFICATION); String ringtoneUri = null; String backupUri = null; Cursor cursor = ringtoneManager.getCursor(); try { cursor.moveToFirst(); while (!cursor.isAfterLast()) { String ringtone = cursor.getString(RingtoneManager.TITLE_COLUMN_INDEX); if (ringtone.equalsIgnoreCase("dDeneb")) { ringtoneUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + cursor.getString(RingtoneManager.ID_COLUMN_INDEX); break; } if (backupUri == null) { backupUri = cursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + cursor.getString(RingtoneManager.ID_COLUMN_INDEX); } cursor.moveToNext(); } } finally { cursor.deactivate(); } SharedPreferences.Editor editor = settings.edit(); if (ringtoneUri != null) { editor.putString("ringtone", ringtoneUri); } else { if (backupUri != null) { editor.putString("ringtone", backupUri.toString()); } else { editor.putString("ringtone", "none"); } } editor.commit(); }
From source file:com.bellman.bible.service.db.mynote.MyNoteDBAdapter.java
public List<MyNoteDto> getMyNotesInBook(BibleBook book) { Log.d(TAG, "about to getMyNotesInPassage:" + book.getOSIS()); List<MyNoteDto> notesList = new ArrayList<MyNoteDto>(); Cursor c = db.query(MyNoteQuery.TABLE, MyNoteQuery.COLUMNS, MyNoteColumn.KEY + " LIKE ?", new String[] { String.valueOf(book.getOSIS() + ".%") }, null, null, null); try {//from w w w .j av a 2s.c o m if (c.moveToFirst()) { while (!c.isAfterLast()) { MyNoteDto mynote = getMyNoteDto(c); notesList.add(mynote); c.moveToNext(); } } } finally { c.close(); } Log.d(TAG, "myNotesInPassage set to " + notesList.size() + " item long list"); return notesList; }
From source file:de.elanev.studip.android.app.frontend.courses.CourseAttendeesFragment.java
public void onLoadFinished(Loader<Cursor> loader, Cursor cursor) { if (getActivity() == null) { return;/* w w w . j a va 2s .co m*/ } List<SectionedCursorAdapter.Section> sections = new ArrayList<SectionedCursorAdapter.Section>(); cursor.moveToFirst(); int prevRole = -1; int currRole = -1; while (!cursor.isAfterLast()) { currRole = cursor .getInt(cursor.getColumnIndex(CoursesContract.Columns.CourseUsers.COURSE_USER_USER_ROLE)); if (currRole != prevRole) { String role = null; switch (currRole) { case CoursesContract.USER_ROLE_TEACHER: role = getString(R.string.Teacher); break; case CoursesContract.USER_ROLE_TUTOR: role = getString(R.string.Tutor); break; case CoursesContract.USER_ROLE_STUDENT: role = getString(R.string.Student); break; default: throw new UnknownError("unknown role type"); } sections.add(new SectionedCursorAdapter.Section(cursor.getPosition(), role)); } prevRole = currRole; cursor.moveToNext(); } mUsersAdapter.setSections(sections); mUsersAdapter.changeCursor(cursor); setLoadingViewVisible(false); }
From source file:edu.auburn.ppl.cyclecolumbus.NoteUploader.java
@Override protected Boolean doInBackground(Long... noteid) { // First, send the note user asked for: Boolean result = true;/*from ww w.j av a 2 s. c o m*/ if (noteid.length != 0) { result = uploadOneNote(noteid[0]); } // Then, automatically try and send previously-completed notes // that were not sent successfully. Vector<Long> unsentNotes = new Vector<Long>(); mDb.openReadOnly(); Cursor cur = mDb.fetchUnsentNotes(); if (cur != null && cur.getCount() > 0) { // pd.setMessage("Sent. You have previously unsent notes; submitting those now."); while (!cur.isAfterLast()) { unsentNotes.add(Long.valueOf(cur.getLong(0))); cur.moveToNext(); } cur.close(); } mDb.close(); for (Long note : unsentNotes) { result &= uploadOneNote(note); } return result; }
From source file:gov.wa.wsdot.android.wsdot.service.CamerasSyncService.java
/** * Check the camera table for any starred entries. If we find some, save them * to a list so we can re-star those cameras after we flush the database. */// w ww . ja va 2 s . com private List<Integer> getStarred() { ContentResolver resolver = getContentResolver(); Cursor cursor = null; List<Integer> starred = new ArrayList<Integer>(); try { cursor = resolver.query(Cameras.CONTENT_URI, new String[] { Cameras.CAMERA_ID }, Cameras.CAMERA_IS_STARRED + "=?", new String[] { "1" }, null); if (cursor != null && cursor.moveToFirst()) { while (!cursor.isAfterLast()) { starred.add(cursor.getInt(0)); cursor.moveToNext(); } } } finally { if (cursor != null) { cursor.close(); } } return starred; }
From source file:com.doctoror.fuckoffmusicplayer.presentation.library.albums.conditional.ConditionalAlbumListFragment.java
@Nullable private String findAlbumArt(@NonNull final Cursor cursor) { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { final String art = cursor.getString(AlbumsProviderKt.COLUMN_ALBUM_ART); if (!TextUtils.isEmpty(art)) { return art; }/* w w w. j a v a 2s . c o m*/ } return null; }