How to Copy a .db File from assets to FileSystem.documentDirectory

Please provide the following:

  1. SDK Version: 36.0.0
  2. Platform: iOS Simulator

I need to copy a .db file from assets to the FileSystem.documentDirectory but I get an error. Here’s the code I’m trying:

    await FileSystem.downloadAsync(
        Asset.fromModule(require('../assets/databases/data.db')).uri,
        `${FileSystem.documentDirectory}SQLite/data.db`
    );

Here’s the error I get:

Unable to resolve module "../assets/databases/data.db"
None of these files exist:
* assets/databases/data.db(.native|.ios.expo.ts|.native.expo.tx|.expo.ts|.ios.expo.tsx|.native.expo.tsx|.expo.tsx|.ios.expo.js|.native.expo.js|.expo.js|.ios.expo.jsx|.native.expo.jsx|.expo.jsx|.ios.ts|.native.ts|.ts|.ios.tsx|.native.tsx|.tsx|.ios.js|.native.js|.js|.ios.jsx|.native.jsx|.jsx|.ios.json|.native.json|.json|.ios.wasm|.native.wasm|.wasm)

How do i copy a .db file from assets to the FileSystem.documentDirectory folder? I just need to copy a .db file from assets to the FileSystem.documentDirectory folder, but this error makes it look like Asset.fromModule only allows image files.

If I use the exact same code but replace the .db file with a .png file, it works.

i am also need this db file and i dont understand how to get it …

my code here just give me the path …but no have path like that , i just want to see my db file and i want to save this file in my desktop . how can i do that ?

const { uri } = await FileSystem.getInfoAsync(
        `${FileSystem.documentDirectory}SQLite/${'places.db'}`
    )
     console.log("THIS IS PATH OF THE DB",uri)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.