當前位置: 首頁>>代碼示例>>Java>>正文


Java SQLiteQueryBuilder.setProjectionMap方法代碼示例

本文整理匯總了Java中android.database.sqlite.SQLiteQueryBuilder.setProjectionMap方法的典型用法代碼示例。如果您正苦於以下問題:Java SQLiteQueryBuilder.setProjectionMap方法的具體用法?Java SQLiteQueryBuilder.setProjectionMap怎麽用?Java SQLiteQueryBuilder.setProjectionMap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.database.sqlite.SQLiteQueryBuilder的用法示例。


在下文中一共展示了SQLiteQueryBuilder.setProjectionMap方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
 * Query the database
 */
private Cursor query(String selection, String[] selectionArgs) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    // main INNER JOIN frequency ON (main._id=freq.pair_id)
    qb.setTables(MAIN_TABLE_NAME + " INNER JOIN " + FREQ_TABLE_NAME + " ON ("
            + MAIN_TABLE_NAME + "." + MAIN_COLUMN_ID + "=" + FREQ_TABLE_NAME + "."
            + FREQ_COLUMN_PAIR_ID +")");

    qb.setProjectionMap(sDictProjectionMap);

    // Get the database and run the query
    SQLiteDatabase db = sOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db,
            new String[] { MAIN_COLUMN_WORD1, MAIN_COLUMN_WORD2, FREQ_COLUMN_FREQUENCY },
            selection, selectionArgs, null, null, null);
    return c;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:21,代碼來源:UserBigramDictionary.java

示例2: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
/**
 * Performs a database query.
 * @param selection The selection clause
 * @param selectionArgs Selection arguments for "?" components in the selection
 * @param columns The columns to return
 * @return A Cursor over all rows matching the query
 */
private Cursor query(String selection, String[] selectionArgs, String[] columns) {
    /* The SQLiteBuilder provides a map for all possible columns requested to
     * actual columns in the database, creating a simple column alias mechanism
     * by which the ContentProvider does not need to know the real column names
     */
    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables(FTS_VIRTUAL_TABLE);
    builder.setProjectionMap(mColumnMap);

    Cursor cursor = builder.query(mDatabaseOpenHelper.getReadableDatabase(),
            columns, selection, selectionArgs, null, null, null);

    if (cursor == null) {
        return null;
    } else if (!cursor.moveToFirst()) {
        cursor.close();
        return null;
    }
    return cursor;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:28,代碼來源:DictionaryDatabase.java

示例3: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection,
                    String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(TABLE_NAME);
    qb.setProjectionMap(values);

    switch (uriMatcher.match(uri)) {
        case API:
            break;
        case API_GET:
            qb.appendWhere(id + "=" + uri.getLastPathSegment());
            break;
        default:
            throw new IllegalArgumentException("Unknown URI : " + uri);
    }
    if (sortOrder == null || sortOrder.equals("")) {
        sortOrder = name;
    }

    Cursor c = qb.query(db, projection, selection, selectionArgs, null,
            null, sortOrder);
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:pulkit4tech,項目名稱:Privy,代碼行數:27,代碼來源:PrivyProvider.java

示例4: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(sqLiteOpenHelper.TABLE_NAME);
    switch (uriMatcher.match(uri)){
        case PLACES_ID:
            queryBuilder.setProjectionMap(PlaceMap);
            break;
        default:
            throw new IllegalArgumentException("Unknown URI " + uri);
    }
    if (sortOrder == null || sortOrder == ""){
        sortOrder = sqLiteOpenHelper.ID;
    }

    Cursor cursor = queryBuilder.query(database, projection, selection,
            selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
}
 
開發者ID:thesabareesh,項目名稱:protrip,代碼行數:21,代碼來源:PlacesProvider.java

示例5: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Nullable
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(Settings.TABLE_NAME);

    switch (sUriMatcher.match(uri)){
        case SETTINGS:
            qb.setProjectionMap(sProjectionMap);
            break;
        case SETTINGS_ID:
            qb.setProjectionMap(sProjectionMap);
            qb.appendWhere(
                    Settings._ID +"="+uri.getPathSegments().get(1)
            );
            break;
        default:
            throw new IllegalArgumentException("Unknown uri: "+uri);
    }

    SQLiteDatabase db = mOPenHelper.getReadableDatabase();
    Cursor c = qb.query(db,projection,selection,selectionArgs,null,null,sortOrder);
    c.setNotificationUri(getContext().getContentResolver(),uri);
    return c;
}
 
開發者ID:coderminer,項目名稱:Demo_Public,代碼行數:26,代碼來源:SettingsProvider.java

示例6: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    switch (URI_MATCHER.match(uri)) {
        case DEBUG_CONFIG_CODE:
            qb.setTables(DEBUG_CONFIG_TABLE);
            qb.setProjectionMap(projectionMap);
            break;

        default:
            throw new IllegalArgumentException("Unknown URI " + uri);
    }

    SQLiteDatabase db = dbHelper.getReadableDatabase();

    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
    if (getContext() != null && getContext().getContentResolver() != null) {
        c.setNotificationUri(getContext().getContentResolver(), uri);
    }
    return c;
}
 
開發者ID:TinkerPatch,項目名稱:tinkerpatch-debug-tool,代碼行數:23,代碼來源:DebugProvider.java

示例7: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor query(String selection, String[] selectionArgs) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(AUTODICT_TABLE_NAME);
    qb.setProjectionMap(sDictProjectionMap);

    // Get the database and run the query
    SQLiteDatabase db = sOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, null, selection, selectionArgs, null, null,
            DEFAULT_SORT_ORDER);
    return c;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:12,代碼來源:AutoDictionary.java

示例8: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection,
		String[] selectionArgs, String sortOrder) {
	SQLiteQueryBuilder sqlBuilder = new SQLiteQueryBuilder();
    sqlBuilder.setTables(EVENTS_TABLE);

    if(uriMatcher.match(uri) == 1){
    	sqlBuilder.setProjectionMap(mMap);
    }else if(uriMatcher.match(uri) == 2){
    	sqlBuilder.setProjectionMap(mMap);
    	sqlBuilder.appendWhere(ID + "=?");
    	selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,new String[] {uri.getLastPathSegment()});
    }else if(uriMatcher.match(uri) == 3){
    	sqlBuilder.setProjectionMap(mMap);
    	sqlBuilder.appendWhere(START + ">=? OR ");
    	sqlBuilder.appendWhere(END + "<=?");
    	List<String> list = uri.getPathSegments();
    	String start = list.get(1);
    	String end = list.get(2);
    	selectionArgs = DatabaseUtils.appendSelectionArgs(selectionArgs,new String[] {start,end});
    }
    if(sortOrder == null || sortOrder == "")
    	sortOrder = START + " COLLATE LOCALIZED ASC";
	Cursor c = sqlBuilder.query(db, projection, selection, selectionArgs,null,null, sortOrder);
	c.setNotificationUri(getContext().getContentResolver(), uri);
	return c;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:28,代碼來源:CalendarProvider.java

示例9: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    switch (sUriMatcher.match(uri)) {
    case ITEMS:
        qb.setTables(TABLE_NAME);
        qb.setProjectionMap(sProjectionMap);
        break;

    case ITEM_ID:
        qb.setTables(TABLE_NAME);
        qb.setProjectionMap(sProjectionMap);
        qb.appendWhere(ShoppingList._ID + "=" + uri.getPathSegments().get(1));
        break;

    default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }

    // If no sort order is specified use the default
    String orderBy;
    if (TextUtils.isEmpty(sortOrder)) {
        orderBy = ShoppingList.DEFAULT_SORT_ORDER;
    } else {
        orderBy = sortOrder;
    }

    // Get the database and run the query
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);

    // Tell the cursor what uri to watch, so it knows when its source data changes
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:38,代碼來源:TrollyProvider.java

示例10: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs,
        String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(NOTES_TABLE_NAME);

    switch (sUriMatcher.match(uri)) {
    case NOTES:
        qb.setProjectionMap(sNotesProjectionMap);
        break;

    case NOTE_ID:
        qb.setProjectionMap(sNotesProjectionMap);
        qb.appendWhere(NoteColumns._ID + "=" + uri.getPathSegments().get(1));
        break;

    case LIVE_FOLDER_NOTES:
        qb.setProjectionMap(sLiveFolderProjectionMap);
        break;

    default:
        throw new IllegalArgumentException("Unknown URI " + uri);
    }

    // If no sort order is specified use the default
    String orderBy;
    if (TextUtils.isEmpty(sortOrder)) {
        orderBy = NoteColumns.DEFAULT_SORT_ORDER;
    } else {
        orderBy = sortOrder;
    }

    // Get the database and run the query
    SQLiteDatabase db = mOpenHelper.getReadableDatabase();
    Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);

    // Tell the cursor what uri to watch, so it knows when its source data changes
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:firebase,項目名稱:firebase-testlab-instr-lib,代碼行數:41,代碼來源:NotePadProvider.java

示例11: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public Cursor query(Uri uri, String[] projection, String selection,String[] selectionArgs, String sortOrder) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(STUDENTS_TABLE_NAME);

    switch (uriMatcher.match(uri)) {
        case STUDENTS:
            qb.setProjectionMap(STUDENTS_PROJECTION_MAP);
            break;

        case STUDENT_ID:
            qb.appendWhere( _ID + "=" + uri.getPathSegments().get(1));
            Log.e("appendWhere",uri.getPathSegments().get(1).toString());
            break;

        default:
            throw new IllegalArgumentException("Unknown URI " + uri);
    }

    if (sortOrder == null || sortOrder == ""){
        /**
         * By default sort on student names
         */
        sortOrder = NAME;
    }
    Cursor c = qb.query(db,	projection,	selection, selectionArgs,null, null, sortOrder);

    /**
     * register to watch a content URI for changes
     */
    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
開發者ID:OWASP,項目名稱:MSTG-Hacking-Playground,代碼行數:34,代碼來源:OMTG_CODING_003_SQL_Injection_Content_Provider_Implementation.java

示例12: findIssueById

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
private Cursor findIssueById(Uri uri, String[] projection) {
    final String issueId = uri.getLastPathSegment();

    final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(IssueEntry.TABLE_NAME
            + " INNER JOIN " + UserEntry.TABLE_NAME
            + " ON " + IssueEntry.TABLE_NAME + ".CREATED_USER_ID = " + UserEntry.TABLE_NAME + "._ID " +
            "LEFT OUTER JOIN " + UserEntry.TABLE_NAME + " AS ASSIGNEE ON "
            + IssueEntry.TABLE_NAME + ".ASSIGNEE_ID = ASSIGNEE._ID " +
            "INNER JOIN " + IssueTypeEntry.TABLE_NAME + " ON " + IssueEntry.TABLE_NAME +
            ".TYPE_ID = " + IssueTypeEntry.TABLE_NAME + "._ID");

    final Map<String, String> columnMap = new HashMap<>();
    columnMap.put(UserEntry.USER_PREFIX + UserEntry.THUMBNAIL_URL, UserEntry.TABLE_NAME + "." + UserEntry.THUMBNAIL_URL);
    columnMap.put(UserEntry.USER_PREFIX + UserEntry.NAME, UserEntry.TABLE_NAME + "." + UserEntry.NAME);
    columnMap.put(IssueEntry.CREATED_DATE, IssueEntry.CREATED_DATE);
    columnMap.put(IssueEntry.DESCRIPTION, IssueEntry.DESCRIPTION);
    columnMap.put(UserEntry.ASSIGNEE_PREFIX + UserEntry.NAME, UserEntry.ASSIGNEE_ALIAS + "." + UserEntry.NAME);
    columnMap.put(IssueEntry.STATUS, IssueEntry.STATUS);
    columnMap.put(IssueEntry.PRIORITY, IssueEntry.PRIORITY);
    columnMap.put(IssueTypeEntry.PREFIX + IssueTypeEntry.NAME, IssueTypeEntry.TABLE_NAME + "." + IssueTypeEntry.NAME);
    columnMap.put(IssueEntry.MILESTONES, IssueEntry.MILESTONES);
    columnMap.put(IssueEntry.SUMMARY, IssueEntry.SUMMARY);
    columnMap.put(IssueEntry.URL, IssueEntry.URL);
    queryBuilder.setProjectionMap(columnMap);
    queryBuilder.appendWhere(IssueEntry.TABLE_NAME + "." + IssueEntry._ID + "=");
    queryBuilder.appendWhere("'" + issueId + "'");

    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    return queryBuilder.query(
            db,
            projection,
            null,
            null,
            null,
            null,
            null);
}
 
開發者ID:scarrupt,項目名稱:Capstone-Project,代碼行數:40,代碼來源:BacklogProvider.java

示例13: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
//查詢操作
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder)
{
	SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
	switch (sUriMatcher.match(uri))
	{
		case CALENDAR:
			qb.setTables(CalendarColumn_TABLE_NAME);
			qb.setProjectionMap(sCalendarColumnProjectionMap);
			break;

		case CALENDAR_ID:
			qb.setTables(CalendarColumn_TABLE_NAME);
			qb.setProjectionMap(sCalendarColumnProjectionMap);
			qb.appendWhere(CalendarColumn._ID + "=" + uri.getPathSegments().get(1));
			break;

		default:
			throw new IllegalArgumentException("Unknown URI " + uri);
	}
	String orderBy;
	if (TextUtils.isEmpty(sortOrder))
	{
		orderBy = CalendarColumns.CalendarColumn.DEFAULT_SORT_ORDER;
	}
	else
	{
		orderBy = sortOrder;
	}
	SQLiteDatabase db = mOpenHelper.getReadableDatabase();
	Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, orderBy);
	c.setNotificationUri(getContext().getContentResolver(), uri);
	return c;
}
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:36,代碼來源:CalendarProvider.java

示例14: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
public Cursor query(Uri uri, String[] projection, String selection,
		String[] selectionArgs, String sortOrder) {
	SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
	UriMatch match = UriMatch.get(uriMatcher.match(uri));

	qb.setProjectionMap(null);	//this should let all the columns through TODO change this later if necessary
	qb.setTables(match.Table.Name);
	//TODO implement the fallback default order later

	// Get the database and run the query
	SQLiteDatabase db = databaseHelper.getReadableDatabase();
	Cursor c = qb.query(db, projection, selection, selectionArgs, null, null, sortOrder);
	return c;
}
 
開發者ID:RestComm,項目名稱:android-QoS,代碼行數:15,代碼來源:Provider.java

示例15: query

import android.database.sqlite.SQLiteQueryBuilder; //導入方法依賴的package包/類
@Override
public synchronized Cursor query(Uri uri, String[] projection,
        String selection, String[] selectionArgs, String sortOrder) {
    if (Utils.doLog())
        Log.d(CLASSNAME, String.format(
                "query() >> uri = %s, selection = %s, sortOrder = %s", uri,
                selection, sortOrder));

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(HistoryContract.TABLE_NAME);
    qb.setProjectionMap(MAP_COLUMNS);

    SQLiteDatabase db = null;
    Cursor cursor = null;

    /*
     * Choose the projection and adjust the "where" clause based on URI
     * pattern-matching.
     */
    switch (URI_MATCHER.match(uri)) {
    case URI_HISTORY: {
        if (Arrays.equals(projection,
                new String[] { HistoryContract._COUNT })) {
            db = mHistoryHelper.getReadableDatabase();
            cursor = db.rawQuery(
                    String.format(
                            "SELECT COUNT(*) AS %s FROM %s %s",
                            HistoryContract._COUNT,
                            HistoryContract.TABLE_NAME,
                            selection != null ? String.format("WHERE %s",
                                    selection) : "").trim(), null);
        }

        break;
    }// URI_HISTORY

    /*
     * If the incoming URI is for a single history item identified by its
     * ID, chooses the history item ID projection, and appends
     * "_ID = <history-item-ID>" to the where clause, so that it selects
     * that single history item.
     */
    case URI_HISTORY_ID: {
        qb.appendWhere(DbUtils.SQLITE_FTS_COLUMN_ROW_ID + " = "
                + uri.getLastPathSegment());

        break;
    }// URI_HISTORY_ID

    default:
        throw new IllegalArgumentException("UNKNOWN URI " + uri);
    }

    if (TextUtils.isEmpty(sortOrder))
        sortOrder = HistoryContract.DEFAULT_SORT_ORDER;

    /*
     * Opens the database object in "read" mode, since no writes need to be
     * done.
     */
    if (Utils.doLog())
        Log.d(CLASSNAME,
                String.format("Going to SQLiteQueryBuilder >> db = %s", db));
    if (db == null) {
        db = mHistoryHelper.getReadableDatabase();
        /*
         * Performs the query. If no problems occur trying to read the
         * database, then a Cursor object is returned; otherwise, the cursor
         * variable contains null. If no records were selected, then the
         * Cursor object is empty, and Cursor.getCount() returns 0.
         */
        cursor = qb.query(db, projection, selection, selectionArgs, null,
                null, sortOrder);
    }

    cursor = appendNameAndRealUri(cursor);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:80,代碼來源:HistoryProvider.java


注:本文中的android.database.sqlite.SQLiteQueryBuilder.setProjectionMap方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。