I have created a local DB that is stored in my iOS device using Expo SqLite and I am having great difficulty accessing the table content to view the data stored.
I have tried the following:
-
I installed the File System Package
npx expo install expo-file-system
-
Then I wanted to see what FileSystem.documentDirectory will log out, because I didn’t know where expo keeps my stuff.
So I simply created a button and onClick I logged the value it returns
FileSystemPath = async () => {
console.log(FileSystem.documentDirectory)
}
This is what is logged: 'file:///var/mobile/Containers/Data/Application/6357EEE7-87AB-437F-81DD-5D4251DB2D90/Documents/ExponentExperienceData/@anonymous/NewLocation-e77cbc5e-75f8-495d-b98f-08cd529311f4/';
I then used the below code to navigate to the directory in my iOS device:
const directoryPath =
"file:///var/mobile/Containers/Data/Application/6357EEE7-87AB-437F-81DD-5D4251DB2D90/Documents/ExponentExperienceData/@anonymous/NewLocation-e77cbc5e-75f8-495d-b98f-08cd529311f4/";
async function shareSQLiteFile() {
try {
const files = await FileSystem.readDirectoryAsync(directoryPath);
if (files.length > 0) {
const filePath = `${directoryPath}/${files[0]}`; // Assuming you want to share the first file
await Sharing.shareAsync(filePath);
console.log("File shared:", filePath);
} else {
console.log("No files in directory");
}
} catch (error) {
console.error("Error sharing file:", error);
}
}
This has allowed me to share the SQLite file on my iOS device and have it saved on the device, but now my issue is that I can’t open the file and there are no suitable file readers available for the document, any advice on how to proceed?
El Wan is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.