我们如何创建新的播放列表并在播放列表中添加或删除歌曲
我创建了一个列表视图,它可以获取手机上可用的所有播放列表并显示在列表中,但我们如何创建新的播放列表以及添加或删除现有播放列表中的歌曲
这是播放列表代码,仅供参考,它没有任何添加或删除任何歌曲的功能
public class playlist extends ListActivity {
//define source of MediaStore.Images.Media, internal or external storage
Uri sourceUri = MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI;
//Uri sourceUri = MediaStore.Images.Media.INTERNAL_CONTENT_URI;
SimpleCursorAdapter mySimpleCursorAdapter;
@SuppressLint("NewApi")
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_main);
String[] from = {MediaStore.Audio.Playlists.NAME};
int[] to = {android.R.id.text1};
CursorLoader cursorLoader = new CursorLoader(
this,
sourceUri,
null,
null,
null,
MediaStore.Audio.Playlists.NAME);
Cursor cursor = cursorLoader.loadInBackground();
mySimpleCursorAdapter = new SimpleCursorAdapter(
this,
android.R.layout.simple_list_item_1,
cursor,
from,
to,
CursorAdapter.FLAG_REGISTER_CONTENT_OBSERVER);
setListAdapter(mySimpleCursorAdapter);
getListView().setOnItemClickListener(myOnItemClickListener);
}