android.database.Cursor

Here are the examples of the java api class android.database.Cursor taken from open source projects.

1. QueryMathTest#testCount()

Project: LitePal
Source File: QueryMathTest.java
View license
public void testCount() {
    int result = DataSupport.count(Student.class);
    int realResult = -100;
    Cursor cursor = DataSupport.findBySQL("select count(1) from " + studentTable);
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    result = DataSupport.where("id > ?", "99").count(studentTable);
    cursor = DataSupport.findBySQL("select count(1) from " + studentTable + " where id > ?", "99");
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    try {
        DataSupport.count("nosuchtable");
        fail();
    } catch (Exception e) {
    }
}

2. QueryMathTest#testAverage()

Project: LitePal
Source File: QueryMathTest.java
View license
public void testAverage() {
    double result = DataSupport.average(Student.class, "age");
    double realResult = -100;
    Cursor cursor = DataSupport.findBySQL("select avg(age) from " + studentTable);
    if (cursor.moveToFirst()) {
        realResult = cursor.getDouble(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    result = DataSupport.where("id > ?", "99").average(studentTable, "age");
    cursor = DataSupport.findBySQL("select avg(age) from " + studentTable + " where id > ?", "99");
    if (cursor.moveToFirst()) {
        realResult = cursor.getDouble(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    try {
        DataSupport.average(Student.class, "nosuchcolumn");
        fail();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

3. QueryMathTest#testMax()

Project: LitePal
Source File: QueryMathTest.java
View license
public void testMax() {
    int result = DataSupport.max(Student.class, "age", Integer.TYPE);
    int realResult = -100;
    Cursor cursor = DataSupport.findBySQL("select max(age) from " + studentTable);
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    result = DataSupport.where("age < ?", "20").max(studentTable, "age", Integer.TYPE);
    cursor = DataSupport.findBySQL("select max(age) from " + studentTable + " where age < ?", "20");
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
}

4. QueryMathTest#testMin()

Project: LitePal
Source File: QueryMathTest.java
View license
public void testMin() {
    int result = DataSupport.min(Student.class, "age", Integer.TYPE);
    int realResult = -100;
    Cursor cursor = DataSupport.findBySQL("select min(age) from " + studentTable);
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    result = DataSupport.where("age > ?", "10").min(studentTable, "age", Integer.TYPE);
    cursor = DataSupport.findBySQL("select min(age) from " + studentTable + " where age > ?", "10");
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
}

5. QueryMathTest#testSum()

Project: LitePal
Source File: QueryMathTest.java
View license
public void testSum() {
    int result = DataSupport.sum(Student.class, "age", Integer.TYPE);
    int realResult = -100;
    Cursor cursor = DataSupport.findBySQL("select sum(age) from " + studentTable);
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
    result = DataSupport.where("age > ?", "15").sum(studentTable, "age", Integer.TYPE);
    cursor = DataSupport.findBySQL("select sum(age) from " + studentTable + " where age > ?", "15");
    if (cursor.moveToFirst()) {
        realResult = cursor.getInt(0);
    }
    cursor.close();
    assertEquals(realResult, result);
}

6. DBReader#getFlattrQueue()

Project: AntennaPod
Source File: DBReader.java
View license
/**
     * Returns the flattr queue as a List of FlattrThings. The list consists of Feeds and FeedItems.
     *
     * @return The flattr queue as a List.
     */
public static List<FlattrThing> getFlattrQueue() {
    Log.d(TAG, "getFlattrQueue() called with: " + "");
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    List<FlattrThing> result = new ArrayList<>();
    // load feeds
    Cursor feedCursor = adapter.getFeedsInFlattrQueueCursor();
    if (feedCursor.moveToFirst()) {
        do {
            result.add(extractFeedFromCursorRow(adapter, feedCursor));
        } while (feedCursor.moveToNext());
    }
    feedCursor.close();
    //load feed items
    Cursor feedItemCursor = adapter.getFeedItemsInFlattrQueueCursor();
    result.addAll(extractItemlistFromCursor(adapter, feedItemCursor));
    feedItemCursor.close();
    adapter.close();
    Log.d(TAG, "Returning flattrQueueIterator for queue with " + result.size() + " items.");
    return result;
}

7. TaskRecorder#getInfo()

View license
private String getInfo(String identifier, String KEY) {
    db = mSQLHelper.getReadableDatabase();
    String selection = KEY_GOOGLE_TASK_IDENTIFIER + "=?";
    String[] selectionArgs = { identifier };
    Cursor cursor = db.query(TASKS_TABLE_NAME, null, selection, selectionArgs, null, null, null);
    int index = cursor.getColumnIndex(KEY);
    if (cursor.isNull(index)) {
        return "0";
    }
    ArrayList<String> list = new ArrayList<String>();
    for (cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()) {
        if (KEY.equals(KEY_COMPLETED) || KEY.equals(KEY_DELETED)) {
            list.add(String.valueOf(cursor.getInt(index)));
        } else {
            list.add(cursor.getString(index));
        }
    }
    cursor.close();
    return list.get(0);
}

8. TaskRecorder#getInfoByID()

View license
private String getInfoByID(int id, String KEY) {
    db = mSQLHelper.getReadableDatabase();
    String selection = KEY_ID + "=?";
    String[] selectionArgs = { String.valueOf(id) };
    Cursor cursor = db.query(TASKS_TABLE_NAME, null, selection, selectionArgs, null, null, null);
    int index = cursor.getColumnIndex(KEY);
    if (cursor.getCount() == 0) {
        return "0";
    }
    ArrayList<String> list = new ArrayList<String>();
    for (cursor.moveToFirst(); !(cursor.isAfterLast()); cursor.moveToNext()) {
        if (KEY.equals(KEY_COMPLETED) || KEY.equals(KEY_DELETED)) {
            list.add(String.valueOf(cursor.getInt(index)));
        } else {
            list.add(cursor.getString(index));
        }
    }
    cursor.close();
    return list.get(0);
}

9. DatabaseCursorTest#testRequery()

View license
@MediumTest
public void testRequery() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.rawQuery("SELECT * FROM test", null);
    assertNotNull(c);
    assertEquals(3, c.getCount());
    c.deactivate();
    c.requery();
    assertEquals(3, c.getCount());
    c.close();
}

10. DatabaseCursorTest#testRequeryWithSelection()

View license
@MediumTest
public void testRequeryWithSelection() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = '" + sString1 + "'", null);
    assertNotNull(c);
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.deactivate();
    c.requery();
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.close();
}

11. DatabaseCursorTest#testRequeryWithSelectionArgs()

View license
@MediumTest
public void testRequeryWithSelectionArgs() throws Exception {
    populateDefaultTable();
    Cursor c = mDatabase.rawQuery("SELECT data FROM test WHERE data = ?", new String[] { sString1 });
    assertNotNull(c);
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.deactivate();
    c.requery();
    assertEquals(1, c.getCount());
    assertTrue(c.moveToFirst());
    assertEquals(sString1, c.getString(0));
    c.close();
}

12. PurchaseDataSource#getEntitlementRecordByReceiptId()

Project: SeriesGuide
Source File: PurchaseDataSource.java
View license
/**
     * Find entitlement record by specified receipt ID.
     */
@Nullable
public PurchaseRecord getEntitlementRecordByReceiptId(final String receiptId) {
    Timber.d("getEntitlementRecordByReceiptId: receiptId (%s)", receiptId);
    final String where = AmazonBillingSQLiteHelper.COLUMN_RECEIPT_ID + "= ?";
    final Cursor cursor = database.query(AmazonBillingSQLiteHelper.TABLE_PURCHASES, allColumns, where, new String[] { receiptId }, null, null, null);
    final PurchaseRecord result;
    cursor.moveToFirst();
    if (cursor.isAfterLast()) {
        result = null;
        Timber.d("getEntitlementRecordByReceiptId: no record found ");
    } else {
        result = cursorToPurchaseRecord(cursor);
        Timber.d("getEntitlementRecordByReceiptId: found ");
    }
    cursor.close();
    return result;
}

13. PurchaseDataSource#getLatestEntitlementRecordBySku()

Project: SeriesGuide
Source File: PurchaseDataSource.java
View license
/**
     * Return the entitlement for given user and sku.
     */
@Nullable
public PurchaseRecord getLatestEntitlementRecordBySku(String userId, String sku) {
    Timber.d("getEntitlementRecordBySku: userId (%s), sku (%s)", userId, sku);
    final String where = AmazonBillingSQLiteHelper.COLUMN_USER_ID + " = ? and " + AmazonBillingSQLiteHelper.COLUMN_SKU + " = ?";
    final Cursor cursor = database.query(AmazonBillingSQLiteHelper.TABLE_PURCHASES, allColumns, where, new String[] { userId, sku }, null, null, AmazonBillingSQLiteHelper.COLUMN_DATE_FROM + " desc ");
    final PurchaseRecord result;
    cursor.moveToFirst();
    if (cursor.isAfterLast()) {
        result = null;
        Timber.d("getEntitlementRecordBySku: no record found ");
    } else {
        result = cursorToPurchaseRecord(cursor);
        Timber.d("getEntitlementRecordBySku: found ");
    }
    cursor.close();
    return result;
}

14. OrgFileTest#testRemoveFileSimple()

Project: mobileorg-android
Source File: OrgFileTest.java
View license
public void testRemoveFileSimple() throws OrgFileNotFoundException {
    OrgFile orgFile = new OrgFile("filename", "name", "checksum");
    orgFile.addFile(resolver);
    OrgFile insertedFile = new OrgFile(orgFile.id, resolver);
    insertedFile.removeFile(resolver);
    Cursor filesCursor = resolver.query(Files.buildIdUri(orgFile.id), Files.DEFAULT_COLUMNS, null, null, null);
    assertEquals(0, filesCursor.getCount());
    filesCursor.close();
    Cursor dataCursor = resolver.query(OrgData.buildIdUri(insertedFile.nodeId), OrgData.DEFAULT_COLUMNS, null, null, null);
    assertEquals(0, dataCursor.getCount());
    dataCursor.close();
}

15. OrgFileTest#testRemoveFileWithNodes()

Project: mobileorg-android
Source File: OrgFileTest.java
View license
public void testRemoveFileWithNodes() throws OrgFileNotFoundException {
    OrgNode node = OrgTestUtils.setupParentScenario(resolver);
    OrgFile orgFile = node.getOrgFile(resolver);
    orgFile.removeFile(resolver);
    Cursor filesCursor = resolver.query(Files.buildIdUri(orgFile.id), Files.DEFAULT_COLUMNS, null, null, null);
    assertEquals(0, filesCursor.getCount());
    filesCursor.close();
    Cursor dataCursor = resolver.query(OrgData.CONTENT_URI, OrgData.DEFAULT_COLUMNS, OrgData.FILE_ID + "=?", new String[] { Long.toString(orgFile.id) }, null);
    assertEquals(0, dataCursor.getCount());
    dataCursor.close();
    OrgTestUtils.cleanupParentScenario(resolver);
}

16. OrgNodeTest#testAddAndUpdateNode()

Project: mobileorg-android
Source File: OrgNodeTest.java
View license
public void testAddAndUpdateNode() throws OrgNodeNotFoundException {
    OrgNode node = OrgTestUtils.getDefaultOrgNode();
    node.write(resolver);
    node.todo = "DONE";
    node.write(resolver);
    Cursor orgDataCursor = resolver.query(OrgData.CONTENT_URI, null, null, null, null);
    assertEquals(1, orgDataCursor.getCount());
    orgDataCursor.close();
    Cursor cursor = resolver.query(OrgData.buildIdUri(node.id), OrgData.DEFAULT_COLUMNS, null, null, null);
    assertNotNull(cursor);
    assertEquals(1, cursor.getCount());
    OrgNode insertedNode = new OrgNode(cursor);
    cursor.close();
    assertTrue(node.equals(insertedNode));
}

17. OrgNodeTest#testArchiveNodeGeneratesEdit()

Project: mobileorg-android
Source File: OrgNodeTest.java
View license
public void testArchiveNodeGeneratesEdit() {
    OrgNode node = OrgTestUtils.getDefaultOrgNode();
    node.write(resolver);
    Cursor editCursor = resolver.query(Edits.CONTENT_URI, Edits.DEFAULT_COLUMNS, null, null, null);
    int baseOfEdits = editCursor.getCount();
    editCursor.close();
    OrgEdit edit = node.archiveNode(resolver);
    edit.type.equals(OrgEdit.TYPE.ARCHIVE);
    Cursor editCursor2 = resolver.query(Edits.CONTENT_URI, Edits.DEFAULT_COLUMNS, null, null, null);
    int numberOfEdits = editCursor2.getCount();
    editCursor2.close();
    assertEquals(baseOfEdits + 1, numberOfEdits);
}

18. OrgNodeTest#testArchiveNodeToSiblingGeneratesEdit()

Project: mobileorg-android
Source File: OrgNodeTest.java
View license
public void testArchiveNodeToSiblingGeneratesEdit() {
    OrgNode node = OrgTestUtils.setupParentScenario(resolver);
    node.write(resolver);
    Cursor editCursor = resolver.query(Edits.CONTENT_URI, Edits.DEFAULT_COLUMNS, null, null, null);
    int baseOfEdits = editCursor.getCount();
    editCursor.close();
    OrgEdit edit = node.archiveNodeToSibling(resolver);
    edit.type.equals(OrgEdit.TYPE.ARCHIVE_SIBLING);
    Cursor editCursor2 = resolver.query(Edits.CONTENT_URI, Edits.DEFAULT_COLUMNS, null, null, null);
    int numberOfEdits = editCursor2.getCount();
    editCursor2.close();
    assertEquals(baseOfEdits + 1, numberOfEdits);
}

19. SQLiteDatabaseTest#testExecSQLInsertNullShouldBeException()

Project: robolectric
Source File: SQLiteDatabaseTest.java
View license
@Test(expected = Exception.class)
public void testExecSQLInsertNullShouldBeException() throws Exception {
    //this inserts null in android, but it when it happens it is likely an error.  H2 throws an exception.  So we'll make Robolectric expect an Exception so that the error can be found.
    database.delete("exectable", null, null);
    Cursor cursor = database.rawQuery("select * from exectable", null);
    cursor.moveToFirst();
    assertThat(cursor.getCount(), equalTo(0));
    database.execSQL("insert into exectable (first_column) values (?);", new String[] {});
    Cursor cursor2 = database.rawQuery("select * from exectable", new String[] { null });
    cursor.moveToFirst();
    assertThat(cursor2.getCount(), equalTo(1));
}

20. DeleteTest#deleteOne()

Project: storio
Source File: DeleteTest.java
View license
@Test
public void deleteOne() {
    final User user = putUserBlocking();
    final Cursor cursorAfterInsert = db.query(UserTableMeta.TABLE, null, null, null, null, null, null);
    assertThat(cursorAfterInsert.getCount()).isEqualTo(1);
    cursorAfterInsert.close();
    deleteUserBlocking(user);
    final Cursor cursorAfterDelete = db.query(UserTableMeta.TABLE, null, null, null, null, null, null);
    assertThat(cursorAfterDelete.getCount()).isEqualTo(0);
    cursorAfterDelete.close();
}

21. DBFreshTest#testFreshInstall()

Project: NotePad
Source File: DBFreshTest.java
View license
@SmallTest
public void testFreshInstall() {
    context.deleteDatabase(PREFIX + LegacyDBHelper.LEGACY_DATABASE_NAME);
    context.deleteDatabase(PREFIX + DatabaseHandler.DATABASE_NAME);
    final SQLiteDatabase db = new DatabaseHandler(context, PREFIX).getReadableDatabase();
    // Just open the database, there should be one list and one task present
    Cursor tlc = db.query(TaskList.TABLE_NAME, TaskList.Columns.FIELDS, null, null, null, null, null);
    assertEquals("Should be ONE list present on fresh installs", 1, tlc.getCount());
    tlc.close();
    Cursor tc = db.query(Task.TABLE_NAME, Task.Columns.FIELDS, null, null, null, null, null);
    assertEquals("Should be NO task present on fresh installs", 0, tc.getCount());
    tc.close();
    db.close();
    assertTrue("Could not delete database", context.deleteDatabase(PREFIX + LegacyDBHelper.LEGACY_DATABASE_NAME));
    assertTrue("Could not delete database", context.deleteDatabase(PREFIX + DatabaseHandler.DATABASE_NAME));
}

22. WayPointsOverlay#refresh()

View license
public void refresh() {
    wayPointItems.clear();
    Cursor c = this.pContentResolver.query(TrackContentProvider.waypointsUri(trackId), null, null, null, TrackContentProvider.Schema.COL_TIMESTAMP + " asc");
    for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
        OverlayItem i = new OverlayItem(c.getString(c.getColumnIndex(Schema.COL_NAME)), c.getString(c.getColumnIndex(Schema.COL_NAME)), new GeoPoint(c.getDouble(c.getColumnIndex(Schema.COL_LATITUDE)), c.getDouble(c.getColumnIndex(Schema.COL_LONGITUDE))));
        wayPointItems.add(i);
    }
    c.close();
    populate();
}

23. LibraryDatabaseHelper#getKeys()

View license
private List<String> getKeys(Field fieldName, Order order) {
    String[] keyField = { fieldName.toString() };
    Cursor fieldCursor = getDataBase().query(LIB_BOOKS_TABLE, keyField, null, new String[0], null, null, fieldName != null ? "LOWER(" + fieldName.toString() + ") " + order.toString() : null);
    List<String> keys = new ArrayList<String>();
    fieldCursor.moveToFirst();
    fieldCursor.moveToFirst();
    while (!fieldCursor.isAfterLast()) {
        keys.add(fieldCursor.getString(0));
        fieldCursor.moveToNext();
    }
    fieldCursor.close();
    return keys;
}

24. DBReader#getPlaybackHistory()

Project: AntennaPod
Source File: DBReader.java
View license
/**
     * Loads the playback history from the database. A FeedItem is in the playback history if playback of the correpsonding episode
     * has been completed at least once.
     *
     * @return The playback history. The FeedItems are sorted by their media's playbackCompletionDate in descending order.
     * The size of the returned list is limited by {@link #PLAYBACK_HISTORY_SIZE}.
     */
public static List<FeedItem> getPlaybackHistory() {
    Log.d(TAG, "getPlaybackHistory() called");
    PodDBAdapter adapter = PodDBAdapter.getInstance();
    adapter.open();
    Cursor mediaCursor = adapter.getCompletedMediaCursor(PLAYBACK_HISTORY_SIZE);
    String[] itemIds = new String[mediaCursor.getCount()];
    for (int i = 0; i < itemIds.length && mediaCursor.moveToPosition(i); i++) {
        int index = mediaCursor.getColumnIndex(PodDBAdapter.KEY_FEEDITEM);
        itemIds[i] = Long.toString(mediaCursor.getLong(index));
    }
    mediaCursor.close();
    Cursor itemCursor = adapter.getFeedItemCursor(itemIds);
    List<FeedItem> items = extractItemlistFromCursor(adapter, itemCursor);
    loadAdditionalFeedItemListData(items);
    itemCursor.close();
    adapter.close();
    Collections.sort(items, new PlaybackCompletionDateComparator());
    return items;
}

25. MySQLiteHelper#queryAll()

Project: AndroidLife
Source File: MySQLiteHelper.java
View license
/**
     * ????
     *
     * @return List list
     */
public List<SQLiteData> queryAll() {
    List<SQLiteData> allData = new ArrayList<>();
    SQLiteDatabase queryAll = this.getReadableDatabase();
    queryAll.beginTransaction();
    String sql = "select * from " + TB_CAMNTER;
    Cursor result = queryAll.rawQuery(sql, null);
    for (result.moveToFirst(); !result.isAfterLast(); result.moveToNext()) {
        SQLiteData data = new SQLiteData();
        data.id = result.getInt(result.getColumnIndex("_id"));
        data.content = result.getString(result.getColumnIndex("content"));
        allData.add(data);
    }
    queryAll.setTransactionSuccessful();
    queryAll.endTransaction();
    result.close();
    return allData;
}

26. BackupManager#needTransGallery()

Project: HeartBeat
Source File: BackupManager.java
View license
public static boolean needTransGallery(Context context) {
    boolean ret = false;
    Cursor eventImage = DatabaseUtils.query(context, ImageTable.NAME, new String[] { ImageTable.ID, ImageTable.URI }, ImageTable.URI + " like ?", new String[] { "%/%" });
    Log.d(TAG, String.format("?????%d????.", eventImage.getCount()));
    if (eventImage.getCount() > 1)
        ret = true;
    eventImage.close();
    if (ret)
        return true;
    Cursor thoughtImage = DatabaseUtils.query(context, ThoughtResTable.NAME, new String[] { ThoughtResTable.ID, ThoughtResTable.TYPE, ThoughtResTable.PATH, ThoughtResTable.THOUGHT_ID }, ThoughtResTable.PATH + " like ?", new String[] { "%/%" });
    Log.d(TAG, String.format("?????%d????.", thoughtImage.getCount()));
    if (thoughtImage.getCount() > 1)
        ret = true;
    thoughtImage.close();
    return ret;
}

27. FileImageTest#gallery()

View license
List<Track> gallery() {
    List<Track> tracks = new ArrayList<>();
    Cursor cursor = getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, null, null, null);
    if (cursor == null || cursor.getCount() == 0)
        return tracks;
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
        int nameIndex = cursor.getColumnIndex(MediaStore.Images.Media.DISPLAY_NAME);
        int pathIndex = cursor.getColumnIndex(MediaStore.Images.Media.DATA);
        String name = cursor.getString(nameIndex);
        String path = cursor.getString(pathIndex);
        Track track = new Track();
        track.setTitle(name);
        track.setUrl(path);
        tracks.add(track);
    }
    cursor.close();
    return tracks;
}

28. PlayCountsHelper#getTopSongs()

Project: vanilla
Source File: PlayCountsHelper.java
View license
/**
	 * Returns a sorted array list of most often listen song ids
	 */
public ArrayList<Long> getTopSongs(int limit) {
    ArrayList<Long> payload = new ArrayList<Long>();
    SQLiteDatabase dbh = getReadableDatabase();
    Cursor cursor = dbh.rawQuery("SELECT type_id FROM " + TABLE_PLAYCOUNTS + " WHERE type=" + MediaUtils.TYPE_SONG + " AND playcount != 0 ORDER BY playcount DESC limit " + limit, null);
    while (cursor.moveToNext()) {
        payload.add(cursor.getLong(0));
    }
    cursor.close();
    dbh.close();
    return payload;
}

29. UserDetailsDBHandler#getCount()

View license
public int getCount() {
    SQLiteDatabase db = getWritableDatabase();
    String query = "SELECT * FROM " + TABLE_NAME + ";";
    Cursor c = db.rawQuery(query, null);
    c.moveToFirst();
    int count = 0;
    while (!c.isAfterLast()) {
        count++;
        c.moveToNext();
    }
    c.close();
    db.close();
    return count;
}

30. MediaDatabase#getSearchhistory()

Project: VCL-Android
Source File: MediaDatabase.java
View license
public synchronized ArrayList<String> getSearchhistory(int size) {
    ArrayList<String> history = new ArrayList<String>();
    Cursor cursor = mDb.query(SEARCHHISTORY_TABLE_NAME, new String[] { SEARCHHISTORY_KEY }, null, null, null, null, SEARCHHISTORY_DATE + " DESC", Integer.toString(size));
    while (cursor.moveToNext()) {
        history.add(cursor.getString(0));
    }
    cursor.close();
    return history;
}

31. VKPaymentsDatabase#getPurchases()

View license
public HashSet<String> getPurchases() {
    SQLiteDatabase db = getReadableDatabase();
    Cursor cursor = db.query(TABLE_PURCHASE_INFO, new String[] { TABLE_PURCHASE_INFO_PURCHASE }, null, null, null, null, null);
    HashSet<String> set = new HashSet<>();
    if (cursor.moveToFirst()) {
        do {
            set.add(cursor.getString(0));
        } while (cursor.moveToNext());
    }
    cursor.close();
    return set;
}

32. QueryCityActivity#initDatas()

Project: WayHoo
Source File: QueryCityActivity.java
View license
private void initDatas() {
    Cursor cityCursor = mContentResolver.query(CityProvider.CITY_CONTENT_URI, null, null, null, null);
    mCities = SystemUtils.getAllCities(cityCursor);
    Cursor hotCityCursor = mContentResolver.query(CityProvider.HOTCITY_CONTENT_URI, null, null, null, null);
    mHotCitys = SystemUtils.getHotCities(hotCityCursor);
    Cursor tmpCityCursor = mContentResolver.query(CityProvider.TMPCITY_CONTENT_URI, null, null, null, null);
    mTmpCitys = SystemUtils.getTmpCities(tmpCityCursor);
}

33. AtUsersDBTask#get()

Project: weiciyuan
Source File: AtUsersDBTask.java
View license
public static List<AtUserBean> get(SQLiteDatabase db, String accountId) {
    List<AtUserBean> msgList = new ArrayList<AtUserBean>();
    String sql = "select * from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + "  = " + accountId + " order by " + AtUsersTable.ID + " desc";
    Cursor c = db.rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(AtUsersTable.JSONDATA));
        try {
            AtUserBean value = gson.fromJson(json, AtUserBean.class);
            msgList.add(value);
        } catch (JsonSyntaxException e) {
            AppLogger.e(e.getMessage());
        }
    }
    c.close();
    return msgList;
}

34. AtUsersDBTask#reduce()

Project: weiciyuan
Source File: AtUsersDBTask.java
View license
private static void reduce(SQLiteDatabase db, String accountId) {
    String searchCount = "select count(" + AtUsersTable.ID + ") as total" + " from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + " = " + accountId;
    int total = 0;
    Cursor c = db.rawQuery(searchCount, null);
    if (c.moveToNext()) {
        total = c.getInt(c.getColumnIndex("total"));
    }
    c.close();
    int needDeletedNumber = total - 15;
    if (needDeletedNumber > 0) {
        String sql = " delete from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ID + " in " + "( select " + AtUsersTable.ID + " from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + " in " + "(" + accountId + ") order by " + AtUsersTable.ID + " asc limit " + needDeletedNumber + " ) ";
        db.execSQL(sql);
    }
}

35. CommentByMeTimeLineDBTask#getPosition()

View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + CommentByMeTable.TABLE_NAME + " where " + CommentByMeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(CommentByMeTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

36. CommentToMeTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + CommentsTable.TABLE_NAME + " where " + CommentsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(CommentsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

37. DatabaseManager#getEmotionsMap()

Project: weiciyuan
Source File: DatabaseManager.java
View license
public Map<String, String> getEmotionsMap() {
    Gson gson = new Gson();
    Map<String, String> map = new HashMap<String, String>();
    String sql = "select * from " + EmotionsTable.TABLE_NAME + " order by " + EmotionsTable.ID + " limit 1 ";
    Cursor c = rsd.rawQuery(sql, null);
    if (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(EmotionsTable.JSONDATA));
        try {
            List<EmotionBean> value = gson.fromJson(json, new TypeToken<ArrayList<EmotionBean>>() {
            }.getType());
            for (EmotionBean bean : value) {
                map.put(bean.getPhrase(), bean.getUrl());
            }
        } catch (JsonSyntaxException e) {
            AppLogger.e(e.getMessage());
        }
    }
    c.close();
    return map;
}

38. DownloadPicturesDBTask#get()

View license
public static String get(String url) {
    Cursor c = getRsd().query(DownloadPicturesTable.TABLE_NAME, null, DownloadPicturesTable.URL + "=?", new String[] { url }, null, null, null);
    String path = null;
    while (c.moveToNext()) {
        path = c.getString(c.getColumnIndex(DownloadPicturesTable.PATH));
        break;
    }
    c.close();
    if (!TextUtils.isEmpty(path)) {
        ContentValues cv = new ContentValues();
        cv.put(DownloadPicturesTable.TIME, System.currentTimeMillis());
        getWsd().update(DownloadPicturesTable.TABLE_NAME, cv, DownloadPicturesTable.PATH + "=?", new String[] { path });
    }
    return path;
}

39. FavouriteDBTask#getPosition()

Project: weiciyuan
Source File: FavouriteDBTask.java
View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + FavouriteTable.TABLE_NAME + " where " + FavouriteTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(FavouriteTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

40. FilterDBTask#getFilterKeywordList()

Project: weiciyuan
Source File: FilterDBTask.java
View license
public static List<String> getFilterKeywordList(int type) {
    List<String> keywordList = new ArrayList<String>();
    String sql = "select * from " + FilterTable.TABLE_NAME + " where " + FilterTable.TYPE + "= " + type + " order by " + FilterTable.ID + " desc ";
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String word = c.getString(c.getColumnIndex(FilterTable.NAME));
        keywordList.add(word);
    }
    c.close();
    return keywordList;
}

41. FriendsTimeLineDBTask#getPosition()

View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + HomeTable.TABLE_NAME + " where " + HomeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

42. FriendsTimeLineDBTask#getRecentGroupId()

View license
public static String getRecentGroupId(String accountId) {
    String sql = "select * from " + HomeTable.TABLE_NAME + " where " + HomeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String id = c.getString(c.getColumnIndex(HomeTable.RECENT_GROUP_ID));
        if (!TextUtils.isEmpty(id)) {
            return id;
        }
    }
    c.close();
    return "0";
}

43. HomeOtherGroupTimeLineDBTask#getPosition()

View license
static TimeLinePosition getPosition(String accountId, String groupId) {
    String sql = "select * from " + HomeOtherGroupTable.TABLE_NAME + " where " + HomeOtherGroupTable.ACCOUNTID + "  = " + accountId + " and " + HomeOtherGroupTable.GROUPID + " = " + groupId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

44. MentionCommentsTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + MentionCommentsTable.TABLE_NAME + " where " + MentionCommentsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MentionCommentsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

45. MentionWeiboTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + RepostsTable.TABLE_NAME + " where " + RepostsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(RepostsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

46. MyStatusDBTask#getPosition()

Project: weiciyuan
Source File: MyStatusDBTask.java
View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + MyStatusTable.TABLE_NAME + " where " + MyStatusTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MyStatusTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return TimeLinePosition.empty();
}

47. NotificationDBTask#getUnreadMsgIds()

Project: weiciyuan
Source File: NotificationDBTask.java
View license
public static Set<String> getUnreadMsgIds(String accountId, UnreadDBType type) {
    HashSet<String> ids = new HashSet<String>();
    String sql = "select * from " + NotificationTable.TABLE_NAME + " where " + NotificationTable.ACCOUNTID + "  = " + accountId + " and " + NotificationTable.TYPE + " = " + type.getValue() + " order by " + NotificationTable.ID + " asc";
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String id = c.getString(c.getColumnIndex(NotificationTable.MSGID));
        ids.add(id);
    }
    c.close();
    return ids;
}

48. NotificationDBTask#needCleanDB()

Project: weiciyuan
Source File: NotificationDBTask.java
View license
private static boolean needCleanDB(String accountId) {
    String searchCount = "select count(" + NotificationTable.MSGID + ") as total" + " from " + NotificationTable.TABLE_NAME + " where " + NotificationTable.ACCOUNTID + " = " + accountId;
    int total = 0;
    Cursor c = getWsd().rawQuery(searchCount, null);
    if (c.moveToNext()) {
        total = c.getInt(c.getColumnIndex("total"));
    }
    c.close();
    return total >= AppConfig.DEFAULT_NOTIFICATION_UNREAD_DB_CACHE_COUNT;
}

49. TopicDBTask#get()

Project: weiciyuan
Source File: TopicDBTask.java
View license
public static ArrayList<String> get(String accountId) {
    ArrayList<String> result = new ArrayList<String>();
    String sql = "select * from " + TopicTable.TABLE_NAME + " where " + TopicTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String topic = c.getString(c.getColumnIndex(TopicTable.TOPIC_NAME));
        result.add(topic);
    }
    c.close();
    return result;
}

50. SqlDBOperate#getUserInfoByID()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ?????????ID ??:????????? ??userInfo?
     */
public UserInfo getUserInfoByID(int id) {
    // db = helper.getWritableDatabase();
    // db.query(table, columns, selection, selectionArgs, groupBy, having,
    // orderBy)
    Cursor cursor = userDataBase.query(userSQLHelper.getTableName(), new String[] { "id", "name", "age", "IMEI", "sex", "ip", "status", "avater", "lastdate", "device", "constellation" }, "id=?", new String[] { String.valueOf(id) }, null, null, null);
    if (cursor.moveToNext()) {
        UserInfo userInfo = new UserInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getString(cursor.getColumnIndex("name")), cursor.getInt(cursor.getColumnIndex("age")), cursor.getString(cursor.getColumnIndex("sex")), cursor.getString(cursor.getColumnIndex("IMEI")), cursor.getString(cursor.getColumnIndex("ip")), cursor.getInt(cursor.getColumnIndex("status")), cursor.getInt(cursor.getColumnIndex("avater")), cursor.getString(cursor.getColumnIndex("lastdate")), cursor.getString(cursor.getColumnIndex("device")), cursor.getString(cursor.getColumnIndex("constellation")));
        cursor.close();
        return userInfo;
    }
    cursor.close();
    return null;
}

51. SqlDBOperate#getUserInfoByIMEI()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ????????IMEI? ??:????????? ??userInfo?
     */
public UserInfo getUserInfoByIMEI(String imei) {
    // db = helper.getWritableDatabase();
    // db.query(table, columns, selection, selectionArgs, groupBy, having,
    // orderBy)
    Cursor cursor = userDataBase.query(userSQLHelper.getTableName(), new String[] { "id", "name", "age", "IMEI", "sex", "ip", "status", "avater", "lastdate", "device", "constellation" }, "IMEI=?", new String[] { imei }, null, null, null);
    if (cursor.moveToNext()) {
        UserInfo userInfo = new UserInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getString(cursor.getColumnIndex("name")), cursor.getInt(cursor.getColumnIndex("age")), cursor.getString(cursor.getColumnIndex("sex")), cursor.getString(cursor.getColumnIndex("IMEI")), cursor.getString(cursor.getColumnIndex("ip")), cursor.getInt(cursor.getColumnIndex("status")), cursor.getInt(cursor.getColumnIndex("avater")), cursor.getString(cursor.getColumnIndex("lastdate")), cursor.getString(cursor.getColumnIndex("device")), cursor.getString(cursor.getColumnIndex("constellation")));
        cursor.close();
        return userInfo;
    }
    cursor.close();
    return null;
}

52. SqlDBOperate#getScrollDataOfUserInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ?????????????? ??:start????count???????(????) ??List<userInfo>
     */
public List<UserInfo> getScrollDataOfUserInfo(int start, int count) {
    List<UserInfo> users = new ArrayList<UserInfo>();
    // db = helper.getWritableDatabase();
    Cursor cursor = userDataBase.query(userSQLHelper.getTableName(), new String[] { "id", "name", "age", "sex", "IMEI", "ip", "status", "avater", "lastdate", "device", "constellation" }, null, null, null, null, "id desc", start + "," + count);
    while (cursor.moveToNext()) {
        users.add(new UserInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getString(cursor.getColumnIndex("name")), cursor.getInt(cursor.getColumnIndex("age")), cursor.getString(cursor.getColumnIndex("sex")), cursor.getString(cursor.getColumnIndex("IMEI")), cursor.getString(cursor.getColumnIndex("ip")), cursor.getInt(cursor.getColumnIndex("status")), cursor.getInt(cursor.getColumnIndex("avater")), cursor.getString(cursor.getColumnIndex("lastdate")), cursor.getString(cursor.getColumnIndex("device")), cursor.getString(cursor.getColumnIndex("constellation"))));
    }
    cursor.close();
    return users;
}

53. SqlDBOperate#getCountOfUserInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ??: ???????????
     */
public long getCountOfUserInfo() {
    // db = helper.getWritableDatabase();
    Cursor cursor = userDataBase.query(userSQLHelper.getTableName(), new String[] { "count(*)" }, null, null, null, null, null);
    if (cursor.moveToNext()) {
        long count = cursor.getLong(0);
        cursor.close();
        return count;
    }
    cursor.close();
    return 0;
}

54. SqlDBOperate#getIDOfChattingInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ??????ID sendID,???ID receiverID?????????????ID
     */
public List<Integer> getIDOfChattingInfo(int senderID, int receiverID) {
    List<Integer> ids = new ArrayList<Integer>();
    Cursor cursor = chatInfoDataBase.query(chatInfoSQLHelper.getTableName(), new String[] { "id" }, "sendID=? and receiverID=?", new String[] { String.valueOf(senderID), String.valueOf(receiverID) }, null, null, null);
    while (cursor.moveToNext()) {
        ids.add(Integer.valueOf(cursor.getInt(cursor.getColumnIndex("id"))));
    }
    cursor.close();
    return ids;
}

55. SqlDBOperate#getAllMessageFromChattingInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ??????ID sendID,???ID receiverID????????????
     */
public List<ChattingInfo> getAllMessageFromChattingInfo(int sendID, int receiverID) {
    List<ChattingInfo> infos = new ArrayList<ChattingInfo>();
    Cursor cursor = chatInfoDataBase.query(chatInfoSQLHelper.getTableName(), new String[] { "id", "sendID", "receiverID", "chatting", "date", "style" }, "sendID=? and receiverID=?", new String[] { String.valueOf(sendID), String.valueOf(receiverID) }, null, null, null);
    while (cursor.moveToNext()) {
        infos.add(new ChattingInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getInt(cursor.getColumnIndex("sendID")), cursor.getInt(cursor.getColumnIndex("receiverID")), cursor.getString(cursor.getColumnIndex("date")), cursor.getString(cursor.getColumnIndex("chatting")), cursor.getInt(cursor.getColumnIndex("style"))));
    }
    cursor.close();
    return infos;
}

56. SqlDBOperate#getScrollDataOfChattingInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ?????????????? ??:start??????count???????(????) ??List<chattingInfo>
     */
public List<ChattingInfo> getScrollDataOfChattingInfo(int start, int count) {
    List<ChattingInfo> info = new ArrayList<ChattingInfo>();
    // db = helper.getWritableDatabase();
    Cursor cursor = chatInfoDataBase.query(chatInfoSQLHelper.getTableName(), new String[] { "id", "sendID", "receiverID", "chatting", "date", "style" }, null, null, null, null, "id desc", start + "," + count);
    while (cursor.moveToNext()) {
        info.add(new ChattingInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getInt(cursor.getColumnIndex("sendID")), cursor.getInt(cursor.getColumnIndex("receiverID")), cursor.getString(cursor.getColumnIndex("date")), cursor.getString(cursor.getColumnIndex("chatting")), cursor.getInt(cursor.getColumnIndex("style"))));
    }
    cursor.close();
    return info;
}

57. SqlDBOperate#getScrollMessageOfChattingInfo()

Project: WifiChat
Source File: SqlDBOperate.java
View license
/*
     * ?????????????? ??:start??????count???????(????) ??List<chattingInfo>
     */
public List<Message> getScrollMessageOfChattingInfo(int start, int count, int senderID, int recieverID) {
    List<Message> messages = new ArrayList<Message>();
    Cursor cursor = chatInfoDataBase.query(chatInfoSQLHelper.getTableName(), new String[] { "id", "sendID", "receiverID", "chatting", "date", "style" }, "(sendID=? and receiverID=?) or (receiverID=? and sendID=?)", new String[] { String.valueOf(senderID), String.valueOf(recieverID), String.valueOf(senderID), String.valueOf(recieverID) }, null, null, "id desc", start + "," + count);
    while (cursor.moveToNext()) {
        Message message = chattingInfoToMessage(new ChattingInfo(cursor.getInt(cursor.getColumnIndex("id")), cursor.getInt(cursor.getColumnIndex("sendID")), cursor.getInt(cursor.getColumnIndex("receiverID")), cursor.getString(cursor.getColumnIndex("date")), cursor.getString(cursor.getColumnIndex("chatting")), cursor.getInt(cursor.getColumnIndex("style"))));
        messages.add(message);
    }
    cursor.close();
    Collections.reverse(messages);
    return messages;
}

58. WordPressDB#loadStatsLogin()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public List<String> loadStatsLogin(int id) {
    Cursor c = db.query(BLOGS_TABLE, new String[] { "dotcom_username", "dotcom_password" }, "id=" + id, null, null, null, null);
    c.moveToFirst();
    List<String> returnVector = new Vector<String>();
    if (c.getString(0) != null) {
        returnVector.add(c.getString(0));
        returnVector.add(decryptPassword(c.getString(1)));
    } else {
        returnVector = null;
    }
    c.close();
    return returnVector;
}

59. WordPressDB#loadCategories()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public List<String> loadCategories(int id) {
    Cursor c = db.query(CATEGORIES_TABLE, new String[] { "id", "wp_id", "category_name" }, "blog_id=" + Integer.toString(id), null, null, null, null);
    int numRows = c.getCount();
    c.moveToFirst();
    List<String> returnVector = new Vector<String>();
    for (int i = 0; i < numRows; ++i) {
        String category_name = c.getString(2);
        if (category_name != null) {
            returnVector.add(category_name);
        }
        c.moveToNext();
    }
    c.close();
    return returnVector;
}

60. WordPressDB#getCategoryId()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public int getCategoryId(int id, String category) {
    Cursor c = db.query(CATEGORIES_TABLE, new String[] { "wp_id" }, "category_name=? AND blog_id=?", new String[] { category, String.valueOf(id) }, null, null, null);
    if (c.getCount() == 0)
        return 0;
    c.moveToFirst();
    int categoryID = 0;
    categoryID = c.getInt(0);
    c.close();
    return categoryID;
}

61. WordPressDB#getCategoryParentId()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public int getCategoryParentId(int id, String category) {
    Cursor c = db.query(CATEGORIES_TABLE, new String[] { "parent_id" }, "category_name=? AND blog_id=?", new String[] { category, String.valueOf(id) }, null, null, null);
    if (c.getCount() == 0)
        return -1;
    c.moveToFirst();
    int categoryParentID = c.getInt(0);
    c.close();
    return categoryParentID;
}

62. WordPressDB#getQuickPressShortcuts()

Project: WordPress-Android
Source File: WordPressDB.java
View license
/*
     * return all QuickPress shortcuts connected with the passed blog
     *
     */
public List<Map<String, Object>> getQuickPressShortcuts(int blogId) {
    Cursor c = db.query(QUICKPRESS_SHORTCUTS_TABLE, new String[] { "id", "accountId", "name" }, "accountId = " + blogId, null, null, null, null);
    String id, name;
    int numRows = c.getCount();
    c.moveToFirst();
    List<Map<String, Object>> blogs = new Vector<Map<String, Object>>();
    for (int i = 0; i < numRows; i++) {
        id = c.getString(0);
        name = c.getString(2);
        if (id != null) {
            Map<String, Object> thisHash = new HashMap<String, Object>();
            thisHash.put("id", id);
            thisHash.put("name", name);
            blogs.add(thisHash);
        }
        c.moveToNext();
    }
    c.close();
    return blogs;
}

63. WordPressDB#getUnmoderatedCommentCount()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public int getUnmoderatedCommentCount(int blogID) {
    int commentCount = 0;
    Cursor c = db.rawQuery("select count(*) from comments where blogID=? AND status='hold'", new String[] { String.valueOf(blogID) });
    int numRows = c.getCount();
    c.moveToFirst();
    if (numRows > 0) {
        commentCount = c.getInt(0);
    }
    c.close();
    return commentCount;
}

64. WordPressDB#getWPCOMBlogID()

Project: WordPress-Android
Source File: WordPressDB.java
View license
public int getWPCOMBlogID() {
    int id = -1;
    Cursor c = db.query(BLOGS_TABLE, new String[] { "id" }, "dotcomFlag=1", null, null, null, null);
    int numRows = c.getCount();
    c.moveToFirst();
    if (numRows > 0) {
        id = c.getInt(0);
    }
    c.close();
    return id;
}

65. TransactionsDbAdapter#getTimestampOfLastModification()

View license
/**
     * Returns the most recent `modified_at` timestamp of non-template transactions in the database
     * @return Last moodified time in milliseconds or current time if there is none in the database
     */
public Timestamp getTimestampOfLastModification() {
    Cursor cursor = mDb.query(TransactionEntry.TABLE_NAME, new String[] { "MAX(" + TransactionEntry.COLUMN_MODIFIED_AT + ")" }, null, null, null, null, null);
    Timestamp timestamp = TimestampHelper.getTimestampFromNow();
    if (cursor.moveToFirst()) {
        String timeString = cursor.getString(0);
        if (timeString != null) {
            //in case there were no transactions in the XML file (account structure only)
            timestamp = TimestampHelper.getTimestampFromUtcString(timeString);
        }
    }
    cursor.close();
    return timestamp;
}

66. AccountPreferencesFragment#onCreate()

View license
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.fragment_account_preferences);
    ActionBar actionBar = ((AppCompatPreferenceActivity) getActivity()).getSupportActionBar();
    actionBar.setHomeButtonEnabled(true);
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(R.string.title_account_preferences);
    mActivity = getActivity();
    Cursor cursor = CommoditiesDbAdapter.getInstance().fetchAllRecords(DatabaseSchema.CommodityEntry.COLUMN_MNEMONIC + " ASC");
    while (cursor.moveToNext()) {
        String code = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_MNEMONIC));
        String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_FULLNAME));
        mCurrencyEntries.add(code + " - " + name);
        mCurrencyEntryValues.add(code);
    }
    cursor.close();
}

67. SettingsActivity#setDefaultCurrencyListener()

View license
/**
     * Load the commodities from the database and set the options on the list preference
     * Also sets this activity as a listener for preference changes
     */
private void setDefaultCurrencyListener() {
    CommoditiesDbAdapter commoditiesDbAdapter = CommoditiesDbAdapter.getInstance();
    List<CharSequence> currencyEntries = new ArrayList<>((int) commoditiesDbAdapter.getRecordsCount());
    List<CharSequence> currencyEntryValues = new ArrayList<>((int) commoditiesDbAdapter.getRecordsCount());
    Cursor cursor = commoditiesDbAdapter.fetchAllRecords(DatabaseSchema.CommodityEntry.COLUMN_MNEMONIC + " ASC");
    while (cursor.moveToNext()) {
        String code = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_MNEMONIC));
        String name = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseSchema.CommodityEntry.COLUMN_FULLNAME));
        currencyEntries.add(code + " - " + name);
        currencyEntryValues.add(code);
    }
    cursor.close();
    CharSequence[] entries = new CharSequence[currencyEntries.size()];
    CharSequence[] entryValues = new CharSequence[currencyEntryValues.size()];
    @SuppressWarnings("deprecation") Preference pref = findPreference(getString(R.string.key_default_currency));
    pref.setSummary(GnuCashApplication.getDefaultCurrencyCode());
    pref.setOnPreferenceChangeListener(this);
    ((ListPreference) pref).setEntries(currencyEntries.toArray(entries));
    ((ListPreference) pref).setEntryValues(currencyEntryValues.toArray(entryValues));
}

68. TransactionsActivity#updateNavigationSelection()

View license
/**
	 * Updates the action bar navigation list selection to that of the current account
	 * whose transactions are being displayed/manipulated
	 */
public void updateNavigationSelection() {
    // set the selected item in the spinner
    int i = 0;
    Cursor accountsCursor = mAccountsDbAdapter.fetchAllRecordsOrderedByFullName();
    while (accountsCursor.moveToNext()) {
        String uid = accountsCursor.getString(accountsCursor.getColumnIndexOrThrow(DatabaseSchema.AccountEntry.COLUMN_UID));
        if (mAccountUID.equals(uid)) {
            mToolbarSpinner.setSelection(i);
            break;
        }
        ++i;
    }
    accountsCursor.close();
}

69. EventUtils#getEvent()

Project: HeartBeat
Source File: EventUtils.java
View license
public static Event getEvent(Context context, long id) {
    Cursor cursor = DatabaseUtils.query(context, EventsTable.NAME, new String[] { EventsTable.ID, EventsTable.EVENT, EventsTable.TIMESTAMP }, EventsTable.ID + "=?", new String[] { String.valueOf(id) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return null;
    }
    cursor.moveToFirst();
    Event e = queryEvent(cursor);
    cursor.close();
    return e;
}

70. EventUtils#getToday()

Project: HeartBeat
Source File: EventUtils.java
View license
public static ArrayList<Event> getToday(Context context) {
    Cursor cursor = DatabaseUtils.queryOrderDesc(context, EventsTable.NAME, new String[] { EventsTable.ID, EventsTable.EVENT, EventsTable.TIMESTAMP }, EventsTable.TIMESTAMP + ">?", new String[] { String.valueOf(TimeUtils.getTodayMillis()) }, EventsTable.TIMESTAMP);
    ArrayList<Event> ret = new ArrayList<>();
    if (cursor.getCount() < 1) {
        cursor.close();
        return ret;
    }
    while (cursor.moveToNext()) {
        ret.add(queryEvent(cursor));
    }
    cursor.close();
    return ret;
}

71. EventUtils#getEvents()

Project: HeartBeat
Source File: EventUtils.java
View license
public static ArrayList<Event> getEvents(Context context, Label label) {
    final String rawSQL = "SELECT " + EventsTable.NAME + "." + EventsTable.ID + ", " + EventsTable.EVENT + ", " + EventsTable.TIMESTAMP + ", " + EventLabelRelationTable.LABEL_ID + " FROM " + EventsTable.NAME + " JOIN " + EventLabelRelationTable.NAME + " ON " + EventsTable.NAME + "." + EventsTable.ID + "=" + EventLabelRelationTable.NAME + "." + EventLabelRelationTable.EVENT_ID + " WHERE " + EventLabelRelationTable.LABEL_ID + "=?" + " ORDER BY " + EventsTable.TIMESTAMP + " DESC;";
    Cursor cursor = DatabaseUtils.getReadableDatabase(context).rawQuery(rawSQL, new String[] { String.valueOf(label.getId()) });
    ArrayList<Event> ret = new ArrayList<>();
    if (cursor.getCount() < 1) {
        cursor.close();
        return ret;
    }
    while (cursor.moveToNext()) {
        ret.add(queryEvent(cursor));
    }
    cursor.close();
    return ret;
}

72. EventUtils#getAllEvents()

Project: HeartBeat
Source File: EventUtils.java
View license
public static ArrayList<Event> getAllEvents(Context context) {
    Cursor cursor = DatabaseUtils.queryAllOrderDesc(context, EventsTable.NAME, new String[] { EventsTable.ID, EventsTable.EVENT, EventsTable.TIMESTAMP }, EventsTable.TIMESTAMP);
    ArrayList<Event> eventList = new ArrayList<>();
    if (cursor.getCount() < 1) {
        cursor.close();
        return eventList;
    }
    while (cursor.moveToNext()) {
        eventList.add(queryEvent(cursor));
    }
    cursor.close();
    return eventList;
}

73. EventUtils#searchEvent()

Project: HeartBeat
Source File: EventUtils.java
View license
public static ArrayList<Event> searchEvent(Context context, String search) {
    Cursor cursor = DatabaseUtils.query(context, EventsTable.NAME, new String[] { EventsTable.ID, EventsTable.EVENT, EventsTable.TIMESTAMP }, EventsTable.EVENT + " like ?", new String[] { "%" + search + "%" });
    ArrayList<Event> ret = new ArrayList<>();
    if (cursor.getCount() < 1) {
        cursor.close();
        return ret;
    }
    while (cursor.moveToNext()) {
        ret.add(0, queryEvent(cursor));
    }
    cursor.close();
    return ret;
}

74. ImageUtils#getRelation()

Project: HeartBeat
Source File: ImageUtils.java
View license
private static long[] getRelation(Context context, long eventId) {
    Cursor cursor = DatabaseUtils.query(context, EventImageRelationTable.NAME, new String[] { EventImageRelationTable.IMAGE_ID }, EventImageRelationTable.EVENT_ID + "=?", new String[] { String.valueOf(eventId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return new long[] {};
    }
    long[] imageIds = new long[cursor.getCount()];
    while (cursor.moveToNext()) {
        imageIds[cursor.getPosition()] = queryImageIdByRelation(cursor);
    }
    cursor.close();
    return imageIds;
}

75. ImageUtils#getImageByImageId()

Project: HeartBeat
Source File: ImageUtils.java
View license
public static Image getImageByImageId(Context context, long imageId) {
    Cursor cursor = DatabaseUtils.query(context, ImageTable.NAME, new String[] { ImageTable.ID, ImageTable.URI }, ImageTable.ID + "=?", new String[] { String.valueOf(imageId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return null;
    }
    cursor.moveToFirst();
    Image i = queryImage(cursor);
    cursor.close();
    return i;
}

76. LabelUtils#getRelativedIds()

Project: HeartBeat
Source File: LabelUtils.java
View license
private static long[] getRelativedIds(Context context, String idField, String getField, long id) {
    Cursor cursor = DatabaseUtils.query(context, EventLabelRelationTable.NAME, new String[] { EventLabelRelationTable.EVENT_ID, EventLabelRelationTable.LABEL_ID }, idField + "=?", new String[] { String.valueOf(id) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return new long[] {};
    }
    long[] ret = new long[cursor.getCount()];
    while (cursor.moveToNext()) {
        ret[cursor.getPosition()] = DatabaseUtils.getLong(cursor, getField);
    }
    cursor.close();
    return ret;
}

77. LabelUtils#getLabelByLabelId()

Project: HeartBeat
Source File: LabelUtils.java
View license
public static Label getLabelByLabelId(Context context, long labelId) {
    Cursor cursor = DatabaseUtils.query(context, LabelsTable.NAME, new String[] { LabelsTable.ID, LabelsTable.LABEL }, LabelsTable.ID + "=?", new String[] { String.valueOf(labelId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return null;
    }
    cursor.moveToFirst();
    Label l = queryLabel(cursor);
    cursor.close();
    return l;
}

78. LabelUtils#getAll()

Project: HeartBeat
Source File: LabelUtils.java
View license
public static ArrayList<Label> getAll(Context context) {
    Cursor cursor = DatabaseUtils.queryAll(context, LabelsTable.NAME, new String[] { LabelsTable.ID, LabelsTable.LABEL });
    ArrayList<Label> ret = new ArrayList<>();
    if (cursor.getCount() < 1) {
        cursor.close();
        return ret;
    }
    while (cursor.moveToNext()) {
        ret.add(queryLabel(cursor));
    }
    cursor.close();
    return ret;
}

79. ThoughtUtils#getThoughtIdsByEventId()

Project: HeartBeat
Source File: ThoughtUtils.java
View license
public static long[] getThoughtIdsByEventId(Context context, long eventId) {
    Cursor cursor = DatabaseUtils.query(context, EventThoughtRelationTable.NAME, new String[] { EventThoughtRelationTable.THOUGHT_ID }, EventThoughtRelationTable.EVENT_ID + "=?", new String[] { String.valueOf(eventId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return new long[] {};
    }
    long[] ret = new long[cursor.getCount()];
    while (cursor.moveToNext()) {
        ret[cursor.getPosition()] = queryId(cursor);
    }
    cursor.close();
    return ret;
}

80. ThoughtUtils#getThoughtById()

Project: HeartBeat
Source File: ThoughtUtils.java
View license
public static Thoughts.Thought getThoughtById(Context context, long thoughtId) {
    Cursor cursor = DatabaseUtils.query(context, ThoughtsTable.NAME, new String[] { ThoughtsTable.ID, ThoughtsTable.THOUGHT, ThoughtsTable.TIMESTAMP }, ThoughtsTable.ID + "=?", new String[] { String.valueOf(thoughtId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return null;
    }
    cursor.moveToFirst();
    Thoughts.Thought ret = queryThought(cursor);
    cursor.close();
    return ret;
}

81. ThoughtUtils#getRes()

Project: HeartBeat
Source File: ThoughtUtils.java
View license
private static ThoughtRes getRes(Context context, long thoughtId) {
    Cursor cursor = DatabaseUtils.query(context, ThoughtResTable.NAME, new String[] { ThoughtResTable.ID, ThoughtResTable.THOUGHT_ID, ThoughtResTable.TYPE, ThoughtResTable.PATH }, ThoughtResTable.THOUGHT_ID + "=?", new String[] { String.valueOf(thoughtId) });
    if (cursor.getCount() < 1) {
        cursor.close();
        return null;
    }
    cursor.moveToFirst();
    ThoughtRes ret = queryThoughtRes(cursor);
    cursor.close();
    return ret;
}

82. DatabaseManager#getEmotionsMap()

Project: iBeebo
Source File: DatabaseManager.java
View license
public Map<String, String> getEmotionsMap() {
    Gson gson = new Gson();
    Map<String, String> map = new HashMap<String, String>();
    String sql = "select * from " + EmotionsTable.TABLE_NAME + " order by " + EmotionsTable.ID + " limit 1 ";
    Cursor c = rsd.rawQuery(sql, null);
    if (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(EmotionsTable.JSONDATA));
        try {
            List<EmotionBean> value = gson.fromJson(json, new TypeToken<ArrayList<EmotionBean>>() {
            }.getType());
            for (EmotionBean bean : value) {
                map.put(bean.getPhrase(), bean.getUrl());
            }
        } catch (JsonSyntaxException e) {
            AppLoggerUtils.e(e.getMessage());
        }
    }
    c.close();
    return map;
}

83. AtUsersDBTask#get()

Project: iBeebo
Source File: AtUsersDBTask.java
View license
public static List<AtUserBean> get(SQLiteDatabase db, String accountId) {
    List<AtUserBean> msgList = new ArrayList<AtUserBean>();
    String sql = "select * from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + "  = " + accountId + " order by " + AtUsersTable.ID + " desc";
    Cursor c = db.rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(AtUsersTable.JSONDATA));
        try {
            AtUserBean value = gson.fromJson(json, AtUserBean.class);
            msgList.add(value);
        } catch (JsonSyntaxException e) {
            AppLoggerUtils.e(e.getMessage());
        }
    }
    c.close();
    return msgList;
}

84. AtUsersDBTask#reduce()

Project: iBeebo
Source File: AtUsersDBTask.java
View license
private static void reduce(SQLiteDatabase db, String accountId) {
    String searchCount = "select count(" + AtUsersTable.ID + ") as total" + " from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + " = " + accountId;
    int total = 0;
    Cursor c = db.rawQuery(searchCount, null);
    if (c.moveToNext()) {
        total = c.getInt(c.getColumnIndex("total"));
    }
    c.close();
    int needDeletedNumber = total - 15;
    if (needDeletedNumber > 0) {
        String sql = " delete from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ID + " in " + "( select " + AtUsersTable.ID + " from " + AtUsersTable.TABLE_NAME + " where " + AtUsersTable.ACCOUNTID + " in " + "(" + accountId + ") order by " + AtUsersTable.ID + " asc limit " + needDeletedNumber + " ) ";
        db.execSQL(sql);
    }
}

85. CommentByMeTimeLineDBTask#getPosition()

View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + CommentByMeTable.TABLE_NAME + " where " + CommentByMeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(CommentByMeTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

86. CommentToMeTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + CommentsTable.TABLE_NAME + " where " + CommentsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(CommentsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

87. DownloadPicturesDBTask#get()

Project: iBeebo
Source File: DownloadPicturesDBTask.java
View license
public static String get(String url) {
    Cursor c = getRsd().query(DownloadPicturesTable.TABLE_NAME, null, DownloadPicturesTable.URL + "=?", new String[] { url }, null, null, null);
    String path = null;
    while (c.moveToNext()) {
        path = c.getString(c.getColumnIndex(DownloadPicturesTable.PATH));
        break;
    }
    c.close();
    if (!TextUtils.isEmpty(path)) {
        ContentValues cv = new ContentValues();
        cv.put(DownloadPicturesTable.TIME, System.currentTimeMillis());
        getWsd().update(DownloadPicturesTable.TABLE_NAME, cv, DownloadPicturesTable.PATH + "=?", new String[] { path });
    }
    return path;
}

88. FavouriteDBTask#getPosition()

Project: iBeebo
Source File: FavouriteDBTask.java
View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + FavouriteTable.TABLE_NAME + " where " + FavouriteTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(FavouriteTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

89. FilterDBTask#getFilterKeywordList()

Project: iBeebo
Source File: FilterDBTask.java
View license
public static List<String> getFilterKeywordList(int type) {
    List<String> keywordList = new ArrayList<String>();
    String sql = "select * from " + FilterTable.TABLE_NAME + " where " + FilterTable.TYPE + "= " + type + " order by " + FilterTable.ID + " desc ";
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String word = c.getString(c.getColumnIndex(FilterTable.NAME));
        keywordList.add(word);
    }
    c.close();
    return keywordList;
}

90. FriendsTimeLineDBTask#getPosition()

Project: iBeebo
Source File: FriendsTimeLineDBTask.java
View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + HomeTable.TABLE_NAME + " where " + HomeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

91. FriendsTimeLineDBTask#getRecentGroupId()

Project: iBeebo
Source File: FriendsTimeLineDBTask.java
View license
public static String getRecentGroupId(String accountId) {
    String sql = "select * from " + HomeTable.TABLE_NAME + " where " + HomeTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String id = c.getString(c.getColumnIndex(HomeTable.RECENT_GROUP_ID));
        if (!TextUtils.isEmpty(id)) {
            return id;
        }
    }
    c.close();
    return "0";
}

92. HomeOtherGroupTimeLineDBTask#getPosition()

View license
static TimeLinePosition getPosition(String accountId, String groupId) {
    String sql = "select * from " + HomeOtherGroupTable.TABLE_NAME + " where " + HomeOtherGroupTable.ACCOUNTID + "  = " + accountId + " and " + HomeOtherGroupTable.GROUPID + " = " + groupId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(HomeOtherGroupTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

93. MentionCommentsTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + MentionCommentsTable.TABLE_NAME + " where " + MentionCommentsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MentionCommentsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

94. MentionWeiboTimeLineDBTask#getPosition()

View license
public static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + RepostsTable.TABLE_NAME + " where " + RepostsTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(RepostsTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

95. MyStatusDBTask#getPosition()

Project: iBeebo
Source File: MyStatusDBTask.java
View license
private static TimeLinePosition getPosition(String accountId) {
    String sql = "select * from " + MyStatusTable.TABLE_NAME + " where " + MyStatusTable.ACCOUNTID + "  = " + accountId;
    Cursor c = getRsd().rawQuery(sql, null);
    Gson gson = new Gson();
    while (c.moveToNext()) {
        String json = c.getString(c.getColumnIndex(MyStatusTable.TIMELINEDATA));
        if (!TextUtils.isEmpty(json)) {
            try {
                TimeLinePosition value = gson.fromJson(json, TimeLinePosition.class);
                c.close();
                return value;
            } catch (JsonSyntaxException e) {
                e.printStackTrace();
            }
        }
    }
    c.close();
    return new TimeLinePosition(0, 0);
}

96. NotificationDBTask#getUnreadMsgIds()

Project: iBeebo
Source File: NotificationDBTask.java
View license
public static Set<String> getUnreadMsgIds(String accountId, UnreadDBType type) {
    HashSet<String> ids = new HashSet<String>();
    String sql = "select * from " + NotificationTable.TABLE_NAME + " where " + NotificationTable.ACCOUNTID + "  = " + accountId + " and " + NotificationTable.TYPE + " = " + type.getValue() + " order by " + NotificationTable.ID + " asc";
    Cursor c = getRsd().rawQuery(sql, null);
    while (c.moveToNext()) {
        String id = c.getString(c.getColumnIndex(NotificationTable.MSGID));
        ids.add(id);
    }
    c.close();
    return ids;
}

97. DatabaseBackend#loadIdentityKeys()

Project: Conversations
Source File: DatabaseBackend.java
View license
public Set<IdentityKey> loadIdentityKeys(Account account, String name, XmppAxolotlSession.Trust trust) {
    Set<IdentityKey> identityKeys = new HashSet<>();
    Cursor cursor = getIdentityKeyCursor(account, name, false);
    while (cursor.moveToNext()) {
        if (trust != null && cursor.getInt(cursor.getColumnIndex(SQLiteAxolotlStore.TRUSTED)) != trust.getCode()) {
            continue;
        }
        try {
            identityKeys.add(new IdentityKey(Base64.decode(cursor.getString(cursor.getColumnIndex(SQLiteAxolotlStore.KEY)), Base64.DEFAULT), 0));
        } catch (InvalidKeyException e) {
            Log.d(Config.LOGTAG, AxolotlService.getLogprefix(account) + "Encountered invalid IdentityKey in database for account" + account.getJid().toBareJid() + ", address: " + name);
        }
    }
    cursor.close();
    return identityKeys;
}

98. ImageDao#getImagesOnly()

Project: digitalocean-swimmer
Source File: ImageDao.java
View license
public List<Image> getImagesOnly() {
    List<Image> images = new ArrayList<>();
    Cursor cursor = db.query(getTableHelper().TABLE_NAME, getTableHelper().getAllColumns(), ImageTable.PUBLIC + " = ? AND " + ImageTable.IS_IN_USE + " = ?", new String[] { "1", "1" }, null, null, ImageTable.NAME);
    if (cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
            Image image = newInstance(cursor);
            images.add(image);
            cursor.moveToNext();
        }
    }
    cursor.close();
    return images;
}

99. ImageDao#getSnapshotsOnly()

Project: digitalocean-swimmer
Source File: ImageDao.java
View license
public List<Image> getSnapshotsOnly() {
    List<Image> snapshots = new ArrayList<>();
    Cursor cursor = db.query(getTableHelper().TABLE_NAME, getTableHelper().getAllColumns(), ImageTable.PUBLIC + " = ? AND " + ImageTable.IS_IN_USE + " = ?", new String[] { "0", "1" }, null, null, ImageTable.NAME);
    if (cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
            Image snapshot = newInstance(cursor);
            snapshots.add(snapshot);
            cursor.moveToNext();
        }
    }
    cursor.close();
    return snapshots;
}

100. RecordDao#getAllByDomain()

Project: digitalocean-swimmer
Source File: RecordDao.java
View license
public List<Record> getAllByDomain(String domainName) {
    List<Record> records = new ArrayList<>();
    Cursor cursor = db.query(getTableHelper().TABLE_NAME, getTableHelper().getAllColumns(), RecordTable.DOMAIN_NAME + " = '" + domainName + "'", null, null, null, null);
    if (cursor.moveToFirst()) {
        while (!cursor.isAfterLast()) {
            Record record = newInstance(cursor);
            records.add(record);
            cursor.moveToNext();
        }
    }
    cursor.close();
    return records;
}