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


Java SQLiteQueryBuilder.query方法代码示例

本文整理汇总了Java中android.database.sqlite.SQLiteQueryBuilder.query方法的典型用法代码示例。如果您正苦于以下问题:Java SQLiteQueryBuilder.query方法的具体用法?Java SQLiteQueryBuilder.query怎么用?Java SQLiteQueryBuilder.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.database.sqlite.SQLiteQueryBuilder的用法示例。


在下文中一共展示了SQLiteQueryBuilder.query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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();
    int uriType = sURIMatcher.match(uri);
    switch (uriType) {
    case SIMPLEENTITY_DIR:
        queryBuilder.setTables(TABLENAME);
        break;
    case SIMPLEENTITY_ID:
        queryBuilder.setTables(TABLENAME);
        queryBuilder.appendWhere(PK + "="
                + uri.getLastPathSegment());
        break;
    default:
        throw new IllegalArgumentException("Unknown URI: " + uri);
    }

    Database db = getDatabase();
    Cursor cursor = queryBuilder.query(((StandardDatabase) db).getSQLiteDatabase(), projection, selection,
            selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);

    return cursor;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:SimpleEntityContentProvider.java

示例2: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    switch (sURLMatcher.match(uri)) {
        case TRANSFER_INSTANCE:
            qb.setTables(Constants.TABLE_NAME);
            break;
        case TRANSFER_INSTANCE_ID:
            qb.setTables(Constants.TABLE_NAME);
            qb.appendWhere(Constants.InstanceColumns.ID + "=");
            qb.appendWhere(uri.getLastPathSegment());
            break;
        default:
            throw new IllegalArgumentException("Unknown URL " + uri);
    }
    SQLiteDatabase database = mDbHelper.getReadableDatabase();
    Cursor ret = qb.query(database, strings, s, strings1, null, null, s1);
    if (ret == null) {
        LogUtils.e(TAG, "query error, uri: " + uri);
    } else {
        ret.setNotificationUri(getContext().getContentResolver(), uri);
    }
    return ret;
}
 
开发者ID:lucky-code,项目名称:Practice,代码行数:25,代码来源:WifiDirectContentProvider.java

示例3: 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();
    checkColumns(projection);

    int type = URI_MATCHER.match(uri);
    switch (type){
        case NOTES:
            queryBuilder.setTables(Constants.NOTES_TABLE);
            break;
        case NOTE:
            queryBuilder.setTables(Constants.NOTES_TABLE);
            queryBuilder.appendWhere(Constants.COLUMN_ID + " = " + uri.getLastPathSegment());
            break;
        default:
            throw new IllegalArgumentException("Unknown URI: " + uri);
    }
    SQLiteDatabase db = dbHelper.getWritableDatabase();
    Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
}
 
开发者ID:Okason,项目名称:SimpleNoteApp,代码行数:23,代码来源:NoteContentProvider.java

示例4: getMoviesFromReferenceTable

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor getMoviesFromReferenceTable(String tableName, String[] projection, String selection,
                                           String[] selectionArgs, String sortOrder) {

    SQLiteQueryBuilder sqLiteQueryBuilder = new SQLiteQueryBuilder();

    // tableName INNER JOIN movies ON tableName.movie_id = movies._id
    sqLiteQueryBuilder.setTables(
            tableName + " INNER JOIN " + MoviesContract.MovieEntry.TABLE_NAME +
                    " ON " + tableName + "." + MoviesContract.COLUMN_MOVIE_ID_KEY +
                    " = " + MoviesContract.MovieEntry.TABLE_NAME + "." + MoviesContract.MovieEntry._ID
    );

    return sqLiteQueryBuilder.query(dbHelper.getReadableDatabase(),
            projection,
            selection,
            selectionArgs,
            null,
            null,
            sortOrder
    );
}
 
开发者ID:maksim-m,项目名称:Popular-Movies-App,代码行数:22,代码来源:MoviesProvider.java

示例5: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
@Override
public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
    int matchCode = mUriMatcher.match(uri);
    if (matchCode < 0) {
        throw new IllegalArgumentException("Invalid query URI: " + uri);
    }
    SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    if (isItemUri(matchCode)) {
        queryBuilder.appendWhere(BaseColumns._ID + "=" + uri.getLastPathSegment());
    }
    queryBuilder.setTables(getTableName(matchCode));
    SQLiteDatabase db = getDatabase(false);
    Cursor cursor = queryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
    cursor.setNotificationUri(getContext().getContentResolver(), uri);
    return cursor;
}
 
开发者ID:apsun,项目名称:QuoteLock,代码行数:17,代码来源:AutoContentProvider.java

示例6: fetchAll

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
/**
 * Return a Cursor that contains all FailedActionParameter records which matches the parameters.
 * 
 * @param failedActionID
 *          is id of failed action it belongs to, or null to fetch any
 * @param actionParameterName
 *          name of action parameter, or null to fetch any
 * @param failedActionParameterData
 *          is the data associated with this parameter, or null to fetch any
 * @return a Cursor that contains all FailedActionParameter records which matches the parameters.
 */
public Cursor fetchAll(Long failedActionID, String actionParameterName, 
    String failedActionParameterData) {

  SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
  qb.setTables(DATABASE_TABLE);
  qb.appendWhere("1=1");
  if (failedActionID != null) {
    qb.appendWhere(" AND " + KEY_FAILEDACTIONID + " = " + failedActionID);
  }
  if (actionParameterName != null) {
    qb.appendWhere(" AND " + KEY_ACTIONPARAMETERNAME + " = " + actionParameterName);
  }
  if (failedActionParameterData != null) {
    qb.appendWhere(" AND " + KEY_FAILEDACTIONPARAMETERDATA + " = ");
    qb.appendWhereEscapeString(failedActionParameterData);
  }
  // Not using additional selections, selectionArgs, groupBy, having, orderBy, set them to null.
  return qb.query(database, KEYS, null, null, null, null, null);
}
 
开发者ID:biotinker,项目名称:LibreTasks,代码行数:31,代码来源:FailedActionParameterDbAdapter.java

示例7: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
protected Cursor query(Uri uri, String tableName, String[] columns, String selection, String[] selectionArgs, String sortOrder) {
    String orderBy = sortOrder;
    if (TextUtils.isEmpty(sortOrder))
        orderBy = "_id asc";
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(tableName);
    mDb = mDbHelper.getWritableDatabase();
    return qb.query(mDb,
            columns,
            selection,
            selectionArgs,
            null,
            null,
            orderBy
    );
}
 
开发者ID:lifechurch,项目名称:nuclei-android,代码行数:17,代码来源:ContentProviderBase.java

示例8: findCommentsByIssueId

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor findCommentsByIssueId(Uri uri, String[] projections, String sortOrder) {
    final String issueId = uri.getPathSegments().get(uri.getPathSegments().size() - 2);

    final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(CommentEntry.TABLE_NAME
            + " INNER JOIN " + UserEntry.TABLE_NAME
            + " ON " + CommentEntry.TABLE_NAME + ".CREATED_USER_ID = " + UserEntry.TABLE_NAME + "._ID "
    );

    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    final String selection = CommentEntry.ISSUE_ID + " = ?";

    return queryBuilder.query(
            db,
            projections,
            selection,
            new String[]{issueId},
            null,
            null,
            sortOrder);
}
 
开发者ID:scarrupt,项目名称:Capstone-Project,代码行数:23,代码来源:BacklogProvider.java

示例9: findIssuesByStatusAndCreated

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private Cursor findIssuesByStatusAndCreated(String[] projections, String status, String created) {
    final SQLiteQueryBuilder queryBuilder = new SQLiteQueryBuilder();
    queryBuilder.setTables(IssueEntry.TABLE_NAME
            + " INNER JOIN " + ProjectEntry.TABLE_NAME
            + " ON " + IssueEntry.TABLE_NAME + "." + IssueEntry.PROJECT_ID
            + "=" + ProjectEntry.TABLE_NAME + "." + ProjectEntry._ID);
    queryBuilder.appendWhere(IssueEntry.STATUS + " = ? ");
    queryBuilder.appendWhere("AND strftime('%s',"
            + IssueEntry.CREATED_DATE + ") - strftime('%s', ? ) > 0");

    final SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    return queryBuilder.query(
            db,
            projections,
            null,
            new String[]{status, created},
            null,
            null,
            IssueEntry.DEFAULT_SORT,
            null,
            null);
}
 
开发者ID:scarrupt,项目名称:Capstone-Project,代码行数:24,代码来源:BacklogProvider.java

示例10: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
@WorkerThread
private Cursor query(Param param){
    SQLiteQueryBuilder sqLiteQueryBuilder = getQueryBuilder();
    Cursor c;
    if(sqLiteQueryBuilder != null){
        c = sqLiteQueryBuilder.query(
                Database.getDatabase(),
                param.projection,
                param.selection,
                param.selectionArgs,
                null, null,
                param.sortOrder
        );
    }
    else {
        c = Database.getDatabase().query(
                getTableName(),
                param.projection,
                param.selection,
                param.selectionArgs,
                null, null,
                param.sortOrder
        );
    }

    return c;
}
 
开发者ID:alexandregpereira,项目名称:goblin-lib,代码行数:28,代码来源:BaseDao.java

示例11: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
public Cursor query(
           Uri uri, 
           String[] projection,
           String selection, 
           String[] selectionArgs, 
           String sortOrder) {
	SQLiteDatabase db = dbHelper.getReadableDatabase();

	List<String> segments = uri.getPathSegments();
	String recordId = segments.get(1);
	String name = segments.get(3);

    SQLiteQueryBuilder builder = new SQLiteQueryBuilder();
    builder.setTables("view_things");
    builder.appendWhere("record_id = '" + recordId + "'");
       builder.appendWhere(" and view_name = '" + name + "'");

       Cursor cursor = 
       builder.query(
              db, 
              projection, 
              selection, 
              selectionArgs,
              null, 
              null, 
              sortOrder);
       
       return cursor;
}
 
开发者ID:Microsoft,项目名称:healthvault-java-sdk,代码行数:30,代码来源:ViewThingsProvider.java

示例12: getMobileServer

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
public MobileServer getMobileServer(long id){
    SQLiteDatabase db = this.getReadableDatabase();

    MobileServer mobileServer = new MobileServer();
    mobileServer.setId(id);

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    qb.setTables(TABLE_SERVERS +
            " JOIN " + TABLE_MOBILE_SERVERS +
            " USING(" + COLUMN_ID + ")");

    Cursor c = qb.query(db,
            new String[]{COLUMN_IS_ENABLED,
                    COLUMN_CERTIFICATE_ID,
                    COLUMN_IP_OR_HOSTNAME,
                    COLUMN_PORT_NUMBER,
                    COLUMN_ROAMING_ALLOWED},
            COLUMN_ID + "=?", new String[]{String.valueOf(id)},
            null, null, null);

    if (c.moveToFirst()){
        mobileServer.setIsEnabled(intToBool(c.getInt(0)));
        mobileServer.setCertificateId(c.getLong(1));
        mobileServer.setIpOrHostname(c.getString(2));
        mobileServer.setPortNumber(c.getInt(3));
        mobileServer.setRoamingAllowed(intToBool(c.getInt(4)));
    }

    c.close();
    db.close();
    return mobileServer;
}
 
开发者ID:rootkiwi,项目名称:an2linuxclient,代码行数:34,代码来源:ServerDatabaseHandler.java

示例13: getAllWifiServers

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private List<WifiServer> getAllWifiServers(){
    List<WifiServer> allWifiServers = new ArrayList<>();
    SQLiteDatabase db = this.getReadableDatabase();

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    qb.setTables(TABLE_SERVERS +
            " JOIN " + TABLE_WIFI_SERVERS +
            " USING(" + COLUMN_ID + ")");

    Cursor c = qb.query(db,
            new String[]{COLUMN_ID,
                    COLUMN_IS_ENABLED,
                    COLUMN_CERTIFICATE_ID,
                    COLUMN_IP_OR_HOSTNAME,
                    COLUMN_PORT_NUMBER,
                    COLUMN_SSID_WHITELIST},
            null, null, null, null, null);

    if (c.moveToFirst()){
        do {
            WifiServer wifiServer = new WifiServer();
            wifiServer.setId(c.getLong(0));
            wifiServer.setIsEnabled(intToBool(c.getInt(1)));
            wifiServer.setCertificateId(c.getLong(2));
            wifiServer.setIpOrHostname(c.getString(3));
            wifiServer.setPortNumber(c.getInt(4));
            wifiServer.setSsidWhitelist(c.getString(5));
            allWifiServers.add(wifiServer);
        } while (c.moveToNext());
    }

    c.close();
    db.close();

    return allWifiServers;
}
 
开发者ID:rootkiwi,项目名称:an2linuxclient,代码行数:38,代码来源:ServerDatabaseHandler.java

示例14: getAllMobileServers

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
private List<MobileServer> getAllMobileServers(){
    List<MobileServer> allWifiAndMobileServers = new ArrayList<>();
    SQLiteDatabase db = this.getReadableDatabase();

    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();

    qb.setTables(TABLE_SERVERS +
            " JOIN " + TABLE_MOBILE_SERVERS +
            " USING(" + COLUMN_ID + ")");

    Cursor c = qb.query(db,
            new String[]{COLUMN_ID,
                    COLUMN_IS_ENABLED,
                    COLUMN_CERTIFICATE_ID,
                    COLUMN_IP_OR_HOSTNAME,
                    COLUMN_PORT_NUMBER,
                    COLUMN_ROAMING_ALLOWED},
            null, null, null, null, null);

    if (c.moveToFirst()){
        do {
            MobileServer wifiAndMobileServer = new MobileServer();
            wifiAndMobileServer.setId(c.getLong(0));
            wifiAndMobileServer.setIsEnabled(intToBool(c.getInt(1)));
            wifiAndMobileServer.setCertificateId(c.getLong(2));
            wifiAndMobileServer.setIpOrHostname(c.getString(3));
            wifiAndMobileServer.setPortNumber(c.getInt(4));
            wifiAndMobileServer.setRoamingAllowed(intToBool(c.getInt(5)));
            allWifiAndMobileServers.add(wifiAndMobileServer);
        } while (c.moveToNext());
    }

    c.close();
    db.close();

    return allWifiAndMobileServers;
}
 
开发者ID:rootkiwi,项目名称:an2linuxclient,代码行数:38,代码来源:ServerDatabaseHandler.java

示例15: query

import android.database.sqlite.SQLiteQueryBuilder; //导入方法依赖的package包/类
@Nullable
@Override
public Cursor query(@NonNull Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
	SQLiteDatabase     db                 = dbHelper.getWritableDatabase();
	SQLiteQueryBuilder sqLiteQueryBuilder = new SQLiteQueryBuilder();
	sqLiteQueryBuilder.setTables(Stats.TABLE_NAME);
	Cursor cursor = sqLiteQueryBuilder.query(db, projection, selection, selectionArgs, null, null, sortOrder);
	cursor.setNotificationUri(context().getContentResolver(), uri);
	return cursor;
}
 
开发者ID:lambdasoup,项目名称:blockvote,代码行数:11,代码来源:StatsProvider.java


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