net.sqlcipher.DatabaseUtils Java Examples

The following examples show how to use net.sqlcipher.DatabaseUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AttachmentDatabase.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
private boolean isDataUsedByAnotherAttachment(@Nullable String data, @NonNull AttachmentId attachmentId) {
  if (data == null) return false;

  SQLiteDatabase database = databaseHelper.getReadableDatabase();
  long           matches  = DatabaseUtils.longForQuery(database,
                                                       "SELECT count(*) FROM " + TABLE_NAME + " WHERE " + DATA + " = ? AND " + UNIQUE_ID + " != ? AND " + ROW_ID + " != ?;",
                                                       new String[]{data,
                                                                    Long.toString(attachmentId.getUniqueId()),
                                                                    Long.toString(attachmentId.getRowId())});

  return matches != 0;
}
 
Example #2
Source File: PersonDBHelper.java    From Android-Debug-Database with Apache License 2.0 4 votes vote down vote up
public int numberOfRows() {
    SQLiteDatabase db = this.getReadableDatabase(DB_PASSWORD);
    int numRows = (int) DatabaseUtils.queryNumEntries(db, PERSON_TABLE_NAME);
    return numRows;
}
 
Example #3
Source File: DictionarySearch.java    From Zom-Android-XMPP with GNU General Public License v3.0 3 votes vote down vote up
public ArrayList<String> getMatchingWords (String queryString)
{
    if (database == null)
        return null;

    ArrayList<String> results = null;

    String queryText = COLUMN_WORD + " LIKE " + DatabaseUtils.sqlEscapeString(queryString + "%");

    //OR " + COLUMN_MEANING + " LIKE '%" + queryString + "%'";

    Cursor cursor = database.getAllEntries(new String[] {COLUMN_WORD}, queryText, null, null, null, COLUMN_WORD, " ASC LIMIT " + QUERY_LIMIT);

    if (cursor != null) {
        if (cursor.getCount() > 0) {

            results = new ArrayList<String>();

            while (cursor.moveToNext()) {
                results.add(cursor.getString(0));

            }

        }

        cursor.close();
    }

    return results;
}