skip to Main Content

I am trying to do a data backup for my React Native App with expo go and expo-file-system

 await Filesystem.writeAsStringAsync(
   Filesystem.documentDirectory! + "GymTracker-Data.json",
   JSON.stringify(exportData)
 )

How do I access this documentDirectory with a file explorer app like File Manager or Amaze File Manager?

I tried printing out the path on the app but I can’t find said path.

2

Answers


  1. documentDirectory is your app’s private internal directory, only accessible by your app. Third party apps like File Manager cannot access it.

    At the moment, expo does not provide any API to write files to ‘download’ or other public directories. But this may change in future. Check these two posts discussing the issue.

    https://forums.expo.dev/t/how-to-save-the-file-to-devices-folder-like-download/2398
    https://expo.canny.io/feature-requests/p/ability-to-save-files-on-internal-storage

    Login or Signup to reply.
  2. you can use the expo-sharing library from expo together with the expo-file-system library.

    With expo-file-system you download it to the internal private directory of your application.

    and with expo-sharing you copy it to the iPhone files folder.

    https://www.farhansayshi.com/post/how-to-save-files-to-a-device-folder-using-expo-and-react-native/

    https://docs.expo.dev/versions/latest/sdk/sharing/#sharingoptions

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search