I'm trying to add functionality to my RN app that will allow users to create a new directory within their phone's file system.
I have tried to write the code so that the function creates a directory in the path /storage/emulated/0/AppName/NewFolder, since /storage/emulated/0 is the same path that is used by other apps I use to store user data (such as recording apps)
makeDirectory = () => {
const { currentFolder, units } = this.props;
const directoryName = 'New Folder'
const currentDirectory = units
const absolutePath = `/storage/emulated/0/MyApp/${currentDirectory}`
RNFS.mkdir(absolutePath)
.then((result) => {
console.log('result', result)
})
.catch((err) => {
console.warn('err', err)
})
}
However, this is just giving me an error: directory could not be created. I feel I am missing something here, and am not supposed to be saving the files like this to the phone's system.
My ultimate goal is to have the app with it's own folder system that will be mirrored within /storage/emulated/0/MyApp/home
const AppFolder = 'DirNameyouwant';
const DirectoryPath= RNFS.ExternalStorageDirectoryPath +'/'+ AppFolder;
RNFS.mkdir(DirectoryPath);
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