当前位置: 首页>>代码示例>>Java>>正文


Java DatabaseUtils.appendValueToSql方法代码示例

本文整理汇总了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;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:22,代码来源:ContactListFilterView.java

示例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;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:26,代码来源:ContactsListFragment.java

示例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);
        }
    }


}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:24,代码来源:ImpsProvider.java

示例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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:32,代码来源:AbstractDaoTestSinglePk.java

示例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;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:40,代码来源:ContactsPickerActivity.java

示例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;
}
 
开发者ID:zom,项目名称:Zom-Android,代码行数:40,代码来源:ConversationListFragment.java

示例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;
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:46,代码来源:AbstractDaoTestSinglePk.java


注:本文中的android.database.DatabaseUtils.appendValueToSql方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。