• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PlaylistsColumns类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name    The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[]{
                PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:30,代码来源:MusicUtils.java


示例2: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 *
 * @param context The {@link Context} to use.
 * @param name    The name of the playlist.
 * @return The ID for a playlist.
 */
public static final long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[]{
                    BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[]{
                    name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:26,代码来源:MusicUtils.java


示例3: getNameForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The id of the playlist.
 * @return The name for a playlist.
 */
public static final String getNameForPlaylist(final Context context, final long id) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
            new String[]{PlaylistsColumns.NAME},
            BaseColumns._ID + "=?",
            new String[]{Long.toString(id)},
            null);
    if (cursor != null) {
        try {
            if (cursor.moveToFirst()) {
                return cursor.getString(0);
            }
        } finally {
            cursor.close();
        }
    }
    // nothing found
    return null;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:25,代码来源:MusicUtils.java


示例4: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @param name
 * @return
 */
public static long createPlaylist(Context context, String name) {

    if (name != null && name.length() > 0) {
        ContentResolver resolver = context.getContentResolver();
        String[] cols = new String[] {
            PlaylistsColumns.NAME
        };
        String whereclause = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cur = resolver.query(Audio.Playlists.EXTERNAL_CONTENT_URI, cols, whereclause,
                null, null);
        if (cur.getCount() <= 0) {
            ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            Uri uri = resolver.insert(Audio.Playlists.EXTERNAL_CONTENT_URI, values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:26,代码来源:MusicUtils.java


示例5: getFavoritesId

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @return
 */
public static long getFavoritesId(Context context) {
    long favorites_id = -1;
    String favorites_where = PlaylistsColumns.NAME + "='" + "Favorites" + "'";
    String[] favorites_cols = new String[] {
        BaseColumns._ID
    };
    Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = query(context, favorites_uri, favorites_cols, favorites_where, null, null);
    if (cursor.getCount() <= 0) {
        favorites_id = createPlaylist(context, "Favorites");
    } else {
        cursor.moveToFirst();
        favorites_id = cursor.getLong(0);
        cursor.close();
    }
    return favorites_id;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:22,代码来源:MusicUtils.java


示例6: removeFromFavorites

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context
 * @param id
 */
public static void removeFromFavorites(Context context, long id) {
    long favorites_id;
    if (id < 0) {
    } else {
        ContentResolver resolver = context.getContentResolver();
        String favorites_where = PlaylistsColumns.NAME + "='" + PLAYLIST_NAME_FAVORITES + "'";
        String[] favorites_cols = new String[] {
            BaseColumns._ID
        };
        Uri favorites_uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
        Cursor cursor = resolver.query(favorites_uri, favorites_cols, favorites_where, null,
                null);
        if (cursor.getCount() <= 0) {
            favorites_id = createPlaylist(context, PLAYLIST_NAME_FAVORITES);
        } else {
            cursor.moveToFirst();
            favorites_id = cursor.getLong(0);
            cursor.close();
        }
        Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
        resolver.delete(uri, Playlists.Members.AUDIO_ID + "=" + id, null);
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:28,代码来源:MusicUtils.java


示例7: getPlaylistName

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param playlist_id
 * @return playlist name
 */
public static String getPlaylistName(Context mContext, long playlist_id) {
    String where = BaseColumns._ID + "=" + playlist_id;
    String[] cols = new String[] {
        PlaylistsColumns.NAME
    };
    Uri uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    Cursor cursor = mContext.getContentResolver().query(uri, cols, where, null, null);
    if (cursor == null){
        return "";
    }
    if (cursor.getCount() <= 0)
        return "";
    cursor.moveToFirst();
    String name = cursor.getString(0);
    cursor.close();
    return name;
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:22,代码来源:MusicUtils.java


示例8: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 *
 * @param context The {@link Context} to use.
 * @param name The name of the playlist.
 * @return The ID for a playlist.
 */
public static long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[] {
                name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:26,代码来源:MusicUtils.java


示例9: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        int count = 1;
        if (cursor != null) {
            count = cursor.getCount();
            cursor.close();
        }
        if (count <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        return -1;
    }
    return -1;
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:31,代码来源:MusicUtils.java


示例10: getIdForPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * Returns The ID for a playlist.
 * 
 * @param context The {@link Context} to use.
 * @param name The name of the playlist.
 * @return The ID for a playlist.
 */
public static final long getIdForPlaylist(final Context context, final String name) {
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, new String[] {
                BaseColumns._ID
            }, PlaylistsColumns.NAME + "=?", new String[] {
                name
            }, PlaylistsColumns.NAME);
    int id = -1;
    if (cursor != null) {
        cursor.moveToFirst();
        if (!cursor.isAfterLast()) {
            id = cursor.getInt(0);
        }
        cursor.close();
        cursor = null;
    }
    return id;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:26,代码来源:MusicUtils.java


示例11: createPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param name The name of the new playlist.
 * @return A new playlist ID.
 */
public static final long createPlaylist(final Context context, final String name) {
    if (name != null && name.length() > 0) {
        final ContentResolver resolver = context.getContentResolver();
        final String[] projection = new String[] {
            PlaylistsColumns.NAME
        };
        final String selection = PlaylistsColumns.NAME + " = '" + name + "'";
        Cursor cursor = resolver.query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                projection, selection, null, null);
        if (cursor.getCount() <= 0) {
            final ContentValues values = new ContentValues(1);
            values.put(PlaylistsColumns.NAME, name);
            final Uri uri = resolver.insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                    values);
            return Long.parseLong(uri.getLastPathSegment());
        }
        if (cursor != null) {
            cursor.close();
            cursor = null;
        }
        return -1;
    }
    return -1;
}
 
开发者ID:micromacer,项目名称:Player-by-TweekProject,代码行数:30,代码来源:MusicUtils.java


示例12: getPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@NonNull
public static Playlist getPlaylist(@NonNull final Context context, final String playlistName) {
    return getPlaylist(makePlaylistCursor(
            context,
            PlaylistsColumns.NAME + "=?",
            new String[]{
                    playlistName
            }
    ));
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:11,代码来源:PlaylistLoader.java


示例13: makePlaylistCursor

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@Nullable
public static Cursor makePlaylistCursor(@NonNull final Context context, final String selection, final String[] values) {
    try {
        return context.getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
                new String[]{
                    /* 0 */
                        BaseColumns._ID,
                    /* 1 */
                        PlaylistsColumns.NAME
                }, selection, values, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:15,代码来源:PlaylistLoader.java


示例14: makePlaylistCursor

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
public static final Cursor makePlaylistCursor(final Context context) {
    return context.getContentResolver().query(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI,
            new String[]{
                    BaseColumns._ID,
                    PlaylistsColumns.NAME
            }, null, null, MediaStore.Audio.Playlists.DEFAULT_SORT_ORDER);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:8,代码来源:PlaylistLoader.java


示例15: getPlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@NonNull
public static Observable<Playlist> getPlaylist(@NonNull final Context context, final String playlistName) {
    return getPlaylist(makePlaylistCursor(
            context,
            PlaylistsColumns.NAME + "=?",
            new String[]{
                    playlistName
            }
    ));
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:11,代码来源:PlaylistLoader.java


示例16: setupFragmentData

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new PlaylistAdapter(getActivity(), R.layout.music_listview_items, null,
            										new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    mSortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    mUri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 5;
    mType = TYPE_PLAYLIST;
    mTitleColumn = PlaylistsColumns.NAME;         
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:13,代码来源:PlaylistsFragment.java


示例17: onCreateContextMenu

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    AdapterContextMenuInfo mi = (AdapterContextMenuInfo)menuInfo;
    menu.add(mFragmentGroupId, PLAY_SELECTION, 0, getResources().getString(R.string.play_all));
    if (mi.id >= 0) {
        menu.add(mFragmentGroupId, RENAME_PLAYLIST, 0, getResources().getString(R.string.rename_playlist));
        menu.add(mFragmentGroupId, DELETE_PLAYLIST, 0, getResources().getString(R.string.delete_playlist));
    }
    mCurrentId = mCursor.getString(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
    String title = mCursor.getString(mCursor.getColumnIndexOrThrow(PlaylistsColumns.NAME));
    menu.setHeaderTitle(title);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:13,代码来源:PlaylistsFragment.java


示例18: renamePlaylist

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
/**
 * @param mContext
 * @param id
 * @param name
 */
public static void renamePlaylist(Context mContext, long id, String name) {

    if (name != null && name.length() > 0) {
        ContentResolver resolver = mContext.getContentResolver();
        ContentValues values = new ContentValues(1);
        values.put(PlaylistsColumns.NAME, name);
        resolver.update(Audio.Playlists.EXTERNAL_CONTENT_URI, values, BaseColumns._ID + "=?",
                new String[] {
                    String.valueOf(id)
                });
        Toast.makeText(mContext, "Playlist renamed", Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:19,代码来源:MusicUtils.java


示例19: setupFragmentData

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new PlaylistAdapter(getActivity(), R.layout.listview_items, null,
            										new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    mSortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    mUri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    mFragmentGroupId = 5;
    mType = TYPE_PLAYLIST;
    mTitleColumn = PlaylistsColumns.NAME;         
}
 
开发者ID:cpoopc,项目名称:com.cp.monsterMod,代码行数:13,代码来源:PlaylistsFragment.java


示例20: onCreateLoader

import android.provider.MediaStore.Audio.PlaylistsColumns; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
    String[] projection = new String[] {
            BaseColumns._ID, PlaylistsColumns.NAME
    };
    Uri uri = Audio.Playlists.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Playlists.DEFAULT_SORT_ORDER;
    return new CursorLoader(getActivity(), uri, projection, null, null, sortOrder);
}
 
开发者ID:liufeiit,项目名称:itmarry,代码行数:10,代码来源:PlaylistsFragment.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TypeResolver类代码示例发布时间:2022-05-22
下一篇:
Java TextPage类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap