playlist is not created on EXTERNAL_CONTENT_URI using contentresolver

时间:2015-07-08 15:53:13

标签: android uri

I am trying to create a playlist using the following code

public class MainActivity extends ActionBarActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ContentValues cv = new ContentValues();

        cv.put(MediaStore.Audio.Playlists.NAME, "123456");

        //Uri uri = getContentResolver().insert(MediaStore.Audio.Playlists.getContentUri("external"), cv);
        Uri uri = getContentResolver().insert(MediaStore.Audio.Playlists.EXTERNAL_CONTENT_URI, cv);
        if (uri != null)
        {
            Toast.makeText(getApplicationContext(),uri.toString(), 
                    Toast.LENGTH_LONG).show();
        }
    }

this just would not create any playlist

if i try INTERNAL_CONTENT_URI the playlist is created but even the default app for music in my phone would not show new playlist created

1 个答案:

答案 0 :(得分:0)

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

是真正的问题。