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


Java DatabaseUtilsCompat类代码示例

本文整理汇总了Java中android.support.v4.database.DatabaseUtilsCompat的典型用法代码示例。如果您正苦于以下问题:Java DatabaseUtilsCompat类的具体用法?Java DatabaseUtilsCompat怎么用?Java DatabaseUtilsCompat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onCreateLoader

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
@Override
public Loader<List<com.rks.musicx.data.model.Album>> onCreateLoader(int id, Bundle args) {
    if (id == albumLoaders) {
        AlbumLoader albumLoader = new AlbumLoader(getContext());
        String[] selectargs = getSelectionArgs();
        String selection = getSelection();
        if (artist.getName() != null) {
            selection = DatabaseUtilsCompat.concatenateWhere(selection, MediaStore.Audio.Albums.ARTIST + " = ?");
            selectargs = DatabaseUtilsCompat.appendSelectionArgs(selectargs, new String[]{artist.getName()});
        }
        albumLoader.setSortOrder(Extras.getInstance().getArtistAlbumSort());
        albumLoader.filterartistsong(selection, selectargs);
        return albumLoader;
    }
    return null;
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:17,代码来源:ArtistFragment.java

示例2: getCursor

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
@Nullable
protected Cursor getCursor(Uri musicUri, String[] projection, String selection, String[] selectionArgs, String filteredFieldName, String filter, String orderBy) {
    if (!Utils.checkPermission(getContext(), Manifest.permission.READ_EXTERNAL_STORAGE)) {
        return null;
    }

    Cursor cursor;
    if (filter != null) {
        if (filter.equals("")) {
            return null; // empty filter means that we don't want any result
        }
        selection = DatabaseUtilsCompat.concatenateWhere(selection, filteredFieldName + " LIKE ?");
        selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs, new String[]{"%" + filter + "%"});

    }

    cursor = getContext().getContentResolver().query(musicUri, projection,
            selection, selectionArgs,
            orderBy);


    return cursor;
}
 
开发者ID:andryr,项目名称:Harmony-Music-Player,代码行数:24,代码来源:BaseLoader.java

示例3: getAlbumCursor

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
private Cursor getAlbumCursor() {

        Uri musicUri = MediaStore.Audio.Albums.EXTERNAL_CONTENT_URI;

        String selection = getSelectionString();
        String[] selectionArgs = getSelectionArgs();
        if (mArtist != null) {
            selection = DatabaseUtilsCompat.concatenateWhere(selection, MediaStore.Audio.Albums.ARTIST + " = ?");
            selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs, new String[]{mArtist});

        }

        String fieldName = MediaStore.Audio.Albums.ALBUM;
        String filter = getFilter();
        return getCursor(musicUri, sProjection, selection, selectionArgs, fieldName, filter);
    }
 
开发者ID:andryr,项目名称:Harmony-Music-Player,代码行数:17,代码来源:AlbumLoader.java

示例4: getCursor

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
@Nullable
private Cursor getCursor(Uri musicUri, String[] projection, String selection, String[] selectionArgs, String filteredFieldName, String filter, String orderBy) {
    if (!Permissions.checkPermission(getContext())) {
        return null;
    }


    if (filter != null) {
        if ("".equals(filter)) {
            return null; // empty filter means that we don't want any result
        }
        selection = DatabaseUtilsCompat.concatenateWhere(selection, filteredFieldName + " LIKE ?");
        selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs, new String[]{"%" + filter + "%"});

    }


    return getContext().getContentResolver().query(musicUri, projection, selection, selectionArgs, orderBy);
}
 
开发者ID:Old-Geek,项目名称:Musique,代码行数:20,代码来源:BaseLoader.java

示例5: delete

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
@Override
public int delete(Uri uri, String selection, String[] selectionArgs)
{
	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
	int count = 0;
	int matched = URI_MATCHER.match(uri);
	boolean isMatch = false;
	int length = tableInfos.length;
	for (int i = 0; i < length; i++)
	{
		TableInfo tableInfo = tableInfos[i];
		if (matched == tableInfo.table)
		{
			count = db.delete(tableInfo.tableName, selection, selectionArgs);
			isMatch = true;
			break;
		}
		else if (matched == tableInfo.table_id)
		{
			String finalWhere = DatabaseUtilsCompat.concatenateWhere(tableInfo.field_id + " = " + ContentUris.parseId(uri), selection);
			count = db.delete(tableInfo.tableName, finalWhere, selectionArgs);
			isMatch = true;
			break;
		}
	}
	if (!isMatch)
	{
		throw new IllegalArgumentException(UNKNOWN_URI_LOG + uri);
	}
	return count;
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:32,代码来源:DataBaseProvider.java

示例6: update

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
@Override
public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs)
{
	SQLiteDatabase db = mOpenHelper.getWritableDatabase();
	int count = 0;
	int matched = URI_MATCHER.match(uri);
	boolean isMatch = false;
	int length = tableInfos.length;
	for (int i = 0; i < length; i++)
	{
		TableInfo tableInfo = tableInfos[i];
		if (matched == tableInfo.table)
		{
			count = db.update(tableInfo.tableName, values, selection, selectionArgs);
			isMatch = true;
			break;
		}
		else if (matched == tableInfo.table_id)
		{
			String finalWhere = DatabaseUtilsCompat.concatenateWhere(tableInfo.field_id + " = " + ContentUris.parseId(uri), selection);
			count = db.update(tableInfo.tableName, values, finalWhere, selectionArgs);
			isMatch = true;
			break;
		}
	}
	if (!isMatch)
	{
		throw new IllegalArgumentException(UNKNOWN_URI_LOG + uri);
	}
	return count;
}
 
开发者ID:libit,项目名称:lr_dialer,代码行数:32,代码来源:DataBaseProvider.java

示例7: query

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
/**
 * Handle incoming queries.
 */
@Override
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {

    // Constructs a new query builder and sets its table name
    SQLiteQueryBuilder qb = new SQLiteQueryBuilder();
    qb.setTables(MainTable.TABLE_NAME);

    switch (mUriMatcher.match(uri)) {
        case MAIN:
            // If the incoming URI is for main table.
            qb.setProjectionMap(mNotesProjectionMap);
            break;

        case MAIN_ID:
            // The incoming URI is for a single row.
            qb.setProjectionMap(mNotesProjectionMap);
            qb.appendWhere(MainTable._ID + "=?");
            selectionArgs = DatabaseUtilsCompat.appendSelectionArgs(selectionArgs,
                    new String[] { uri.getLastPathSegment() });
            break;

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


    if (TextUtils.isEmpty(sortOrder)) {
        sortOrder = MainTable.DEFAULT_SORT_ORDER;
    }

    SQLiteDatabase db = mOpenHelper.getReadableDatabase();

    Cursor c = qb.query(db, projection, selection, selectionArgs,
            null /* no group */, null /* no filter */, sortOrder);

    c.setNotificationUri(getContext().getContentResolver(), uri);
    return c;
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:43,代码来源:LoaderThrottleSupport.java

示例8: delete

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
/**
 * Handle deleting data.
 */
@Override
public int delete(Uri uri, String where, String[] whereArgs) {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    String finalWhere;

    int count;

    switch (mUriMatcher.match(uri)) {
        case MAIN:
            // If URI is main table, delete uses incoming where clause and args.
            count = db.delete(MainTable.TABLE_NAME, where, whereArgs);
            break;

            // If the incoming URI matches a single note ID, does the delete based on the
            // incoming data, but modifies the where clause to restrict it to the
            // particular note ID.
        case MAIN_ID:
            // If URI is for a particular row ID, delete is based on incoming
            // data but modified to restrict to the given ID.
            finalWhere = DatabaseUtilsCompat.concatenateWhere(
                    MainTable._ID + " = " + ContentUris.parseId(uri), where);
            count = db.delete(MainTable.TABLE_NAME, finalWhere, whereArgs);
            break;

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

    getContext().getContentResolver().notifyChange(uri, null);

    return count;
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:36,代码来源:LoaderThrottleSupport.java

示例9: update

import android.support.v4.database.DatabaseUtilsCompat; //导入依赖的package包/类
/**
 * Handle updating data.
 */
@Override
public int update(Uri uri, ContentValues values, String where, String[] whereArgs) {
    SQLiteDatabase db = mOpenHelper.getWritableDatabase();
    int count;
    String finalWhere;

    switch (mUriMatcher.match(uri)) {
        case MAIN:
            // If URI is main table, update uses incoming where clause and args.
            count = db.update(MainTable.TABLE_NAME, values, where, whereArgs);
            break;

        case MAIN_ID:
            // If URI is for a particular row ID, update is based on incoming
            // data but modified to restrict to the given ID.
            finalWhere = DatabaseUtilsCompat.concatenateWhere(
                    MainTable._ID + " = " + ContentUris.parseId(uri), where);
            count = db.update(MainTable.TABLE_NAME, values, finalWhere, whereArgs);
            break;

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

    getContext().getContentResolver().notifyChange(uri, null);

    return count;
}
 
开发者ID:reknih,项目名称:informant-droid,代码行数:32,代码来源:LoaderThrottleSupport.java


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