本文整理汇总了Java中android.provider.MediaStore.Audio.PlaylistsColumns类的典型用法代码示例。如果您正苦于以下问题:Java PlaylistsColumns类的具体用法?Java PlaylistsColumns怎么用?Java PlaylistsColumns使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PlaylistsColumns类属于android.provider.MediaStore.Audio包,在下文中一共展示了PlaylistsColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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
}
));
}
示例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;
}
}
示例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);
}
示例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
}
));
}