當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。