Got errors when executing insert new data into content provider,see below code, PS.I just put below codes directly into onCreate() of Activity,then execute.
ContentValues values=new ContentValues();
values.put(MediaStore.Audio.Media.TITLE,"Example Song");
values.put(MediaStore.Audio.Media.ARTIST,"Unknown");
getContentResolver().insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,values);
just simply insert new song data, but got below error occurs.
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.lastIndexOf(int)' on a null object reference
at android.os.Parcel.readException(Parcel.java:1605)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
at android.content.ContentResolver.insert(ContentResolver.java:1254)
at com.example.flover.contentproviderdemo.MainActivity.onCreate(MainActivity.java:48)
Could anyone tell me why? Thanks in advance.