Java Code Examples for net.sqlcipher.DatabaseUtils

The following examples show how to use net.sqlcipher.DatabaseUtils. These examples are extracted from open source projects. 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
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 Project: Android-Debug-Database   Source File: PersonDBHelper.java    License: 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
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;
}