本文整理汇总了Java中android.provider.MediaStore.Audio.PlaylistsColumns.NAME属性的典型用法代码示例。如果您正苦于以下问题:Java PlaylistsColumns.NAME属性的具体用法?Java PlaylistsColumns.NAME怎么用?Java PlaylistsColumns.NAME使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.MediaStore.Audio.PlaylistsColumns
的用法示例。
在下文中一共展示了PlaylistsColumns.NAME属性的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPlaylist
/**
* @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: createPlaylist
/**
* @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;
}
示例3: getFavoritesId
/**
* @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;
}
示例4: removeFromFavorites
/**
* @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);
}
}
示例5: getPlaylistName
/**
* @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;
}
示例6: createPlaylist
/**
* @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;
}
示例7: createPlaylist
/**
* @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;
}
示例8: setupFragmentData
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;
}
示例9: setupFragmentData
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;
}
示例10: onCreateLoader
@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);
}
示例11: addToFavorites
/**
* @param context
* @param id
*/
public static void addToFavorites(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();
}
String[] cols = new String[] {
Playlists.Members.AUDIO_ID
};
Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
Cursor cur = resolver.query(uri, cols, null, null, null);
int base = cur.getCount();
cur.moveToFirst();
while (!cur.isAfterLast()) {
if (cur.getLong(0) == id)
return;
cur.moveToNext();
}
cur.close();
ContentValues values = new ContentValues();
values.put(Playlists.Members.AUDIO_ID, id);
values.put(Playlists.Members.PLAY_ORDER, base + 1);
resolver.insert(uri, values);
}
}
示例12: isFavorite
/**
* @param context
* @param id
* @return
*/
public static boolean isFavorite(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();
}
String[] cols = new String[] {
Playlists.Members.AUDIO_ID
};
Uri uri = Playlists.Members.getContentUri(EXTERNAL, favorites_id);
Cursor cur = resolver.query(uri, cols, null, null, null);
cur.moveToFirst();
while (!cur.isAfterLast()) {
if (cur.getLong(0) == id) {
cur.close();
return true;
}
cur.moveToNext();
}
cur.close();
return false;
}
return false;
}