List of usage examples for android.database Cursor isAfterLast
boolean isAfterLast();
From source file:com.mattprecious.notisync.db.DbAdapter.java
public List<PrimaryProfile> getPrimaryProfiles() { List<PrimaryProfile> profiles = new ArrayList<PrimaryProfile>(); Cursor c = db.query(DbHelper.PRIMARY_PROFILES_TABLE_NAME, null, null, null, null, null, DbHelper.PRIMARY_PROFILES_KEY_NAME + " COLLATE NOCASE ASC"); c.moveToFirst();/* w w w . ja v a 2s . c om*/ while (!c.isAfterLast()) { PrimaryProfile profile = cursorToPrimaryProfile(c); profiles.add(profile); c.moveToNext(); } c.close(); return profiles; }
From source file:com.google.android.apps.santatracker.data.DestinationDbHelper.java
public long getFirstDeparture() { SQLiteDatabase db = getReadableDatabase(); Cursor c = db.rawQuery("SELECT " + COLUMN_NAME_DEPARTURE + " FROM " + TABLE_NAME + " ORDER BY " + COLUMN_NAME_DEPARTURE + " ASC LIMIT 1", null); c.moveToFirst();//from w ww . ja va 2 s . c om long l; if (c.isAfterLast()) { l = -1; } else { l = c.getLong(c.getColumnIndex(COLUMN_NAME_DEPARTURE)); } c.close(); return l; }
From source file:com.google.android.apps.santatracker.data.DestinationDbHelper.java
public long getLastDeparture() { SQLiteDatabase db = getReadableDatabase(); Cursor c = db.rawQuery("SELECT " + COLUMN_NAME_DEPARTURE + " FROM " + TABLE_NAME + " ORDER BY " + COLUMN_NAME_DEPARTURE + " DESC LIMIT 1", null); c.moveToFirst();/*from ww w. j ava2 s . c o m*/ long l; if (c.isAfterLast()) { l = -1; } else { l = c.getLong(c.getColumnIndex(COLUMN_NAME_DEPARTURE)); } c.close(); return l; }
From source file:com.mattprecious.notisync.db.DbAdapter.java
public List<SecondaryProfile> getSecondaryProfiles() { List<SecondaryProfile> profiles = new ArrayList<SecondaryProfile>(); Cursor c = db.query(DbHelper.SECONDARY_PROFILES_TABLE_NAME, null, null, null, null, null, DbHelper.SECONDARY_PROFILES_KEY_NAME + " COLLATE NOCASE ASC"); c.moveToFirst();/* w ww . ja v a 2 s. c o m*/ while (!c.isAfterLast()) { SecondaryProfile profile = cursorToSecondaryProfile(c); profiles.add(profile); c.moveToNext(); } c.close(); return profiles; }
From source file:be.vbsteven.bmtodesk.SendAllCurrentBookmarksActivity.java
protected ArrayList<Bookmark> getAllBookmarks() { ArrayList<Bookmark> result = new ArrayList<SendAllCurrentBookmarksActivity.Bookmark>(); String[] projection = new String[] { BookmarkColumns.TITLE, BookmarkColumns.URL }; Cursor c = managedQuery(Browser.BOOKMARKS_URI, projection, "bookmark = ?", new String[] { "1" }, null); if (c.moveToFirst()) { int title = c.getColumnIndex(BookmarkColumns.TITLE); int url = c.getColumnIndex(BookmarkColumns.URL); while (!c.isAfterLast()) { Bookmark b = new Bookmark(); b.title = c.getString(title); b.url = c.getString(url);/*from w w w .ja va2 s .co m*/ result.add(b); c.moveToNext(); } } return result; }
From source file:com.crankworks.cycletracks.TripUploader.java
@Override protected Boolean doInBackground(Long... tripid) { // First, send the trip user asked for: Boolean result = uploadOneTrip(tripid[0]); // Then, automatically try and send previously-completed trips // that were not sent successfully. Vector<Long> unsentTrips = new Vector<Long>(); mDb.openReadOnly();/*from w w w .java2s. co m*/ Cursor cur = mDb.fetchUnsentTrips(); if (cur != null && cur.getCount() > 0) { //pd.setMessage("Sent. You have previously unsent trips; submitting those now."); while (!cur.isAfterLast()) { unsentTrips.add(new Long(cur.getLong(0))); cur.moveToNext(); } cur.close(); } mDb.close(); for (Long trip : unsentTrips) { result &= uploadOneTrip(trip); } return result; }
From source file:edu.cwru.apo.Directory.java
private void loadTable() { ProgressDialog progDialog = ProgressDialog.show(this, "Loading", "Please Wait", false); userTable.removeAllViews();//from w w w. j a v a 2s.c o m Cursor results = database.query("phoneDB", new String[] { "first", "last", "_id", "phone" }, null, null, null, null, "first"); String rowText = ""; TableRow row; TextView text; if (!results.moveToFirst()) return; while (!results.isAfterLast()) { String phoneNumber = removeNonDigits(results.getString(3)); if (!(phoneNumber == null || phoneNumber.trim().equals("") || phoneNumber.trim().equals("null"))) { rowText = results.getString(0) + " " + results.getString(1) + " [" + results.getString(2) + "]"; row = new TableRow(this); text = new TextView(this); row.setPadding(0, 5, 0, 5); text.setClickable(true); text.setOnClickListener(this); //text.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); text.setText(rowText); userTable.addView(row); row.addView(text); } results.moveToNext(); } progDialog.cancel(); }
From source file:com.appjma.appdeployer.service.Downloader.java
public void syncApps(String token, Uri uri) throws ClientProtocolException, IOException, JSONException, TooManyRecords, WrongHttpResponseCode, UnauthorizedResponseCode { String selection = AppContract.Apps.SYNCED + " = 0"; String[] PROJECTION = new String[] { AppContract.Apps.APP_ID, AppContract.Apps.GUID, AppContract.Apps.NAME, AppContract.Apps.DELETED };// ww w.j a v a 2 s . c om Cursor cursor = mCr.query(uri, PROJECTION, selection, null, null); try { for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) { String id = cursor.getString(0); String guid = cursor.getString(1); String name = cursor.getString(2); boolean deleted = cursor.getInt(3) == 0 ? false : true; if (deleted == true) { checkState(guid != null, "Row could not be marked as deleted if it is not synced"); deleteApp(token, id, guid); } else if (guid == null) { insertApp(token, id, name); } else { updateApp(token, id, guid, name); } } } finally { cursor.close(); } }
From source file:net.naonedbus.manager.impl.FavoriManager.java
/** * Transformer un curseur en liste d'lments * //from w ww . j a v a2 s .c o m * @param c * un Curseur * @return une liste d'lments */ protected List<Favori> getFromCursorFull(final Cursor c) { final List<Favori> items = new ArrayList<Favori>(); if (c.getCount() > 0) { c.moveToFirst(); while (!c.isAfterLast()) { items.add(getSingleFromCursorFull(c)); c.moveToNext(); } } c.close(); return items; }
From source file:com.futureplatforms.kirin.extensions.databases.DatabasesBackend.java
public JSONArray coerceToJSONArray(String[] columnNames, Cursor cursor) { JSONArray array = new JSONArray(); while (!cursor.isAfterLast()) { JSONObject obj = coerceToJSONObject(columnNames, cursor); array.put(obj);/*from w w w. j av a 2 s .c o m*/ cursor.moveToNext(); } return array; }