DocumentFile.createFile() returns null ( java.lang.IllegalArgumentException ) on some Android 10 devices.
Most of them are HUAWEI devices: VOG-L29, MAR-LX1A, ...
Some users have reported this, but I can't figure out why. I don't have a device with this problem, so I can't test it.
It works without problems on most devices.
Has anyone solved this problem?
Uri treeUri = <from ACTION_OPEN_DOCUMENT_TREE result> ( content://com.android.externalstorage.documents/tree/4A21-0000:Photos )
DocumentFile docFile = DocumentFile.fromTreeUri( context, treeUri );
DocumentFile resultFile = docFile.createFile( "image/jpeg", "IMG_20200327_144048.jpg" );
resultFile is null !!!
Log received from user:
onActivityResult: requestCode=1,resultCode=-1,data=Intent { dat=content://com.android.externalstorage.documents/tree/4A21-0000:Photos flg=0xc3 }
DocumentsContract: Failed to create document
DocumentsContract: java.lang.IllegalArgumentException: Requested path /mnt/media_rw/4A21-0000/Photos/IMG_20200327_144048.jpg doesn't appear under [/system/media, /hw_product/hw_oem/VOG-L29/media, /system/product/media]
DocumentsContract: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
DocumentsContract: at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
DocumentsContract: at android.content.ContentProviderProxy.call(ContentProviderNative.java:658)
DocumentsContract: at android.content.ContentResolver.call(ContentResolver.java:2080)
DocumentsContract: at android.provider.DocumentsContract.createDocument(DocumentsContract.java:1327)
...