Skip to content

MattNer0/react-native-android-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-android-fs

React Native Android module to use Android's Storage Access Framework and DocumentsProvier to access files on the device.

Installation

yarn add react-native-android-fs

Add it to your android project

  • Link automatically with (if your version of react-native doesn't support autolinking):
react-native link react-native-android-fs

Usage

import AndroidFs from 'react-native-android-fs'
// pick directory and read content
AndroidFs.openDirectoryPicker(async (treeUri) => {
  const contentArray = await AndroidFs.readDir(treeUri)
  for (let i=0; i<contentArray.length; i++) {
    console.log(contentArray[i])
    /*
      {
        'name'         : <string>,
        'path'         : <string>,
        'lastModified' : <number>,
        'isDirectory'  : <boolean>,
        'isFile'       : <boolean>
      }
    */
  }
})
// create new directory
const newPath = await AndroidFs.mkdir(path, name)
// create new file
const newPath = await AndroidFs.touch(path, filename, mimeType)
// write text file
await AndroidFs.writeTextFile(fileUri, text)
// read file content
const contentString = await AndroidFs.readTextFile(fileUri)
// delete file
await AndroidFs.delete(fileUri)

License

MIT

Releases

No releases published

Packages

No packages published