Uri uri = contentResolver.insert(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, audioValues);
on some devices yields:
java.lang.UnsupportedOperationException: Unknown URI: content://media/external/audio/media at android.app.ActivityThread.handleCreateService(ActivityThread.java:2887) at android.app.ActivityThread.-wrap4(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5422) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by java.lang.UnsupportedOperationException: Unknown URI: content://media/external/audio/media at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:167) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135) at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476) at android.content.ContentResolver.insert(ContentResolver.java:1231) at company.app.MainService.setupFilesForAudioRecording(MainService.java:388) at company.app.MainService.onCreate(MainService.java:239) at android.app.ActivityThread.handleCreateService(ActivityThread.java:2877) at android.app.ActivityThread.-wrap4(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1427) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5422) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
I don't understand how it is possible I would ever get this error. How can MediaStore.Audio.Media.EXTERNAL_CONTENT_URI be an unknown URI? Is this a situation where the device does not have external storage?
Developer docs say:
External storage is not always available, because the user can mount the external storage as USB storage and in some cases remove it from the device.
But that seems like a very rare case.