I'm developing application where I've to select a folder from external storage and then I've to get its path which I later pass to fileobserver. everything is working fine. I'm using this code to select directory:
Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT_TREE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
startActivityForResult(intent,RESULT_CODE);
and it gives me this interface: directory chooser
Problem: when I run app on KITKAT it gives me above mentioned exception. I've searched it over internet but could not figure out alternative for this. I just want to select directory and get its path on kikat.
ACTION_OPEN_DOCUMENT_TREE was added in API 21 (Lollipop) - it does not exist on API 19 (Kitkat) devices and there is no equivalent for pre-API 21 devices.
You'll need to request the READ_EXTERNAL_STORAGE permission and build your own file browser from scratch if you want to let users select a folder on Kitkat devices.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With