本文整理汇总了Java中android.database.DatabaseUtils.appendValueToSql方法的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtils.appendValueToSql方法的具体用法?Java DatabaseUtils.appendValueToSql怎么用?Java DatabaseUtils.appendValueToSql使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.database.DatabaseUtils
的用法示例。
在下文中一共展示了DatabaseUtils.appendValueToSql方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateLoader
import android.database.DatabaseUtils; //导入方法依赖的package包/类
@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;
}
示例2: onCreateLoader
import android.database.DatabaseUtils; //导入方法依赖的package包/类
@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;
}
示例3: appendWhere
import android.database.DatabaseUtils; //导入方法依赖的package包/类
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);
}
}
}
示例4: queryWithDummyColumnsInFront
import android.database.DatabaseUtils; //导入方法依赖的package包/类
protected Cursor queryWithDummyColumnsInFront(int dummyCount, String valueForColumn, K pk) {
StringBuilder builder = new StringBuilder("SELECT ");
for (int i = 0; i < dummyCount; i++) {
builder.append(valueForColumn).append(",");
}
SqlUtils.appendColumns(builder, "T", dao.getAllColumns()).append(" FROM ");
builder.append('"').append(dao.getTablename()).append('"').append(" T");
if (pk != null) {
builder.append(" WHERE ");
assertEquals(1, dao.getPkColumns().length);
builder.append(dao.getPkColumns()[0]).append("=");
DatabaseUtils.appendValueToSql(builder, pk);
}
String select = builder.toString();
Cursor cursor = db.rawQuery(select, null);
assertTrue(cursor.moveToFirst());
try {
for (int i = 0; i < dummyCount; i++) {
assertEquals(valueForColumn, cursor.getString(i));
}
if (pk != null) {
assertEquals(1, cursor.getCount());
}
} catch (RuntimeException ex) {
cursor.close();
throw ex;
}
return cursor;
}
示例5: onCreateLoader
import android.database.DatabaseUtils; //导入方法依赖的package包/类
@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('(');
buf.append(Imps.Contacts.TYPE).append('=').append(Imps.Contacts.TYPE_NORMAL);
if (mShowGroups) {
buf.append(" OR ");
buf.append(Imps.Contacts.TYPE).append('=').append(Imps.Contacts.TYPE_GROUP);
}
buf.append(')');
buf.append(" AND ");
buf.append('(');
buf.append(Imps.Contacts.SUBSCRIPTION_TYPE).append("==").append(Imps.Contacts.SUBSCRIPTION_TYPE_BOTH);
buf.append(" OR ");
buf.append(Imps.Contacts.SUBSCRIPTION_TYPE).append("==").append(Imps.Contacts.SUBSCRIPTION_TYPE_TO);
buf.append(')');
CursorLoader loader = new CursorLoader(ContactsPickerActivity.this, mUri, ContactListItem.CONTACT_PROJECTION,
buf == null ? null : buf.toString(), null, Imps.Contacts.MODE_AND_ALPHA_SORT_ORDER);
// loader.setUpdateThrottle(50L);
return loader;
}
示例6: onCreateLoader
import android.database.DatabaseUtils; //导入方法依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
StringBuilder buf = new StringBuilder();
CursorLoader loader = null;
//search nickname, jabber id, or last message
if (!TextUtils.isEmpty(mSearchString)) {
mUri = Imps.Messages.CONTENT_URI_MESSAGES_BY_SEARCH;
// buf.append("contacts." + Imps.Contacts.NICKNAME);
// buf.append(" LIKE ");
// DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%");
// buf.append(" OR ");
buf.append(Imps.Messages.BODY);
buf.append(" LIKE ");
DatabaseUtils.appendValueToSql(buf, "%" + mSearchString + "%");
loader = new CursorLoader(getActivity(), mUri, null,
buf == null ? null : buf.toString(), null, Imps.Messages.REVERSE_SORT_ORDER);
}
else
{
mUri = Imps.Contacts.CONTENT_URI_CHAT_CONTACTS_BY;
if (mFilterArchive)
buf.append(Imps.Chats.CHAT_TYPE + '=' + Imps.Chats.CHAT_TYPE_ARCHIVED);
else
buf.append("(" + Imps.Chats.CHAT_TYPE + " IS NULL")
.append(" OR " + Imps.Chats.CHAT_TYPE + '=' + Imps.Chats.CHAT_TYPE_MUTED)
.append(" OR " + Imps.Chats.CHAT_TYPE + '=' + Imps.Chats.CHAT_TYPE_ACTIVE + ")");
loader = new CursorLoader(getActivity(), mUri, CHAT_PROJECTION,
buf == null ? null : buf.toString(), null, Imps.Contacts.TIME_ORDER);
}
return loader;
}
示例7: queryWithDummyColumnsInFront
import android.database.DatabaseUtils; //导入方法依赖的package包/类
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;
}