A React Native module that allows you to use native UI to select a directory from the device library
$ npm install git+https://github.com/lokdevp/react-native-directory-picker.git
$ react-native link
<!-- file: android/src/main/AndroidManifest.xml -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myApp">
<!-- add following permissions -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<!-- -->
...
- In your React Native javascript code, bring in the native module:
import DirectoryPickerManager from 'react-native-directory-picker';
- Use it like so:
When you want to display the picker:
DirectoryPickerManager.showDirectoryPicker(null, (response) => {
console.log('Response = ', response);
if (response.didCancel) {
console.log('User cancelled directory picker');
}
else if (response.error) {
console.log('DirectoryPickerManager Error: ', response.error);
}
else {
this.setState({
directory: response
});
}
});