Java Code Examples for android.database.DatabaseUtils#appendValueToSql()
The following examples show how to use
android.database.DatabaseUtils#appendValueToSql() .
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: ContactsListFragment.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append(Imps.Contacts.TYPE).append('=').append(mType); // buf.append(" ) GROUP BY(" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(getActivity(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.SUB_AND_ALPHA_SORT_ORDER); return loader; }
Example 2
Source File: ContactListFilterView.java From zom-android-matrix with Apache License 2.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); } CursorLoader loader = new CursorLoader(getContext(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.DEFAULT_SORT_ORDER); // loader.setUpdateThrottle(10L); return loader; }
Example 3
Source File: ContactListFilterView.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); } CursorLoader loader = new CursorLoader(getContext(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.DEFAULT_SORT_ORDER); // loader.setUpdateThrottle(10L); return loader; }
Example 4
Source File: ContactsListFragment.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (mSearchString != null) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append(Imps.Contacts.TYPE).append('=').append(mType); // buf.append(" ) GROUP BY(" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(getActivity(), mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.SUB_AND_ALPHA_SORT_ORDER); return loader; }
Example 5
Source File: ImpsProvider.java From Zom-Android-XMPP with GNU General Public License v3.0 | 6 votes |
private static void appendWhere(StringBuilder where, String columnName, String condition, Object value) { if (where.length() > 0) { StringBuilder newCond = new StringBuilder(); newCond.append(columnName).append(condition); if (value != null) { DatabaseUtils.appendValueToSql(newCond, value); } newCond.append(" AND ("); where.insert(0,newCond.toString()); where.append(")"); } else { where.append(columnName).append(condition); if (value != null) { DatabaseUtils.appendValueToSql(where, value); } } }
Example 6
Source File: ContactsPickerActivity.java From Zom-Android-XMPP with GNU General Public License v3.0 | 5 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (!TextUtils.isEmpty(mSearchString)) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append('('); buf.append(Imps.Contacts.TYPE).append('=').append(Imps.Contacts.TYPE_NORMAL); if (mShowGroups) { buf.append(" OR (") // Mask out TYPE_FLAG_UNSEEN, we want unseen groups as well! .append(Imps.Contacts.TYPE) .append(" & (~") .append(Imps.Contacts.TYPE_FLAG_UNSEEN) .append("))") .append('=').append(Imps.Contacts.TYPE_GROUP); } // buf.append(") "); buf.append(")) GROUP BY (" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(ContactsPickerActivity.this, mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.MODE_AND_ALPHA_SORT_ORDER); return loader; }
Example 7
Source File: ContactsPickerActivity.java From zom-android-matrix with Apache License 2.0 | 4 votes |
@Override public Loader<Cursor> onCreateLoader(int id, Bundle args) { StringBuilder buf = new StringBuilder(); if (!TextUtils.isEmpty(mSearchString)) { buf.append('('); buf.append(Imps.Contacts.NICKNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(" OR "); buf.append(Imps.Contacts.USERNAME); buf.append(" LIKE "); DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%"); buf.append(')'); buf.append(" AND "); } buf.append('('); if (mShowGroups) { buf.append("(") // Mask out TYPE_FLAG_UNSEEN, we want unseen groups as well! .append(Imps.Contacts.TYPE) .append(" & (~") .append(Imps.Contacts.TYPE_FLAG_UNSEEN) .append("))") .append('=').append(Imps.Contacts.TYPE_GROUP); } else { buf.append(Imps.Contacts.TYPE).append('=').append(Imps.Contacts.TYPE_NORMAL); } // buf.append(") "); buf.append(")) GROUP BY (" + Imps.Contacts.USERNAME); CursorLoader loader = new CursorLoader(ContactsPickerActivity.this, mUri, ContactListItem.CONTACT_PROJECTION, buf == null ? null : buf.toString(), null, Imps.Contacts.ALPHA_SORT_ORDER); return loader; }
Example 8
Source File: AbstractDaoTestSinglePk.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
protected Cursor queryWithDummyColumnsInFront(int i, String s, Object obj) { int j = 0; StringBuilder stringbuilder = new StringBuilder("SELECT "); for (int k = 0; k < i; k++) { stringbuilder.append(s).append(","); } SqlUtils.appendColumns(stringbuilder, "T", dao.getAllColumns()).append(" FROM "); stringbuilder.append(dao.getTablename()).append(" T"); if (obj != null) { stringbuilder.append(" WHERE "); assertEquals(1, dao.getPkColumns().length); stringbuilder.append(dao.getPkColumns()[0]).append("="); DatabaseUtils.appendValueToSql(stringbuilder, obj); } String s1 = stringbuilder.toString(); Cursor cursor = db.rawQuery(s1, null); assertTrue(cursor.moveToFirst()); do { if (j >= i) { break; } try { assertEquals(s, cursor.getString(j)); } catch (RuntimeException runtimeexception) { cursor.close(); throw runtimeexception; } j++; } while (true); if (obj == null) { break MISSING_BLOCK_LABEL_198; } assertEquals(1, cursor.getCount()); return cursor; }