using expo sqlite, I want to use my existing db that exists in assets folder without trying to move/copy the file to files folder. is that possible?
here is the code that expo uses
import * as FileSystem from 'expo-file-system';
import * as SQLite from 'expo-sqlite';
import { Asset } from 'expo-asset';
async function openDatabase(pathToDatabaseFile: string): Promise<SQLite.WebSQLDatabase> {
if (!(await FileSystem.getInfoAsync(FileSystem.documentDirectory + 'SQLite')).exists) {
await FileSystem.makeDirectoryAsync(FileSystem.documentDirectory + 'SQLite');
}
await FileSystem.downloadAsync(
Asset.fromModule(require(pathToDatabaseFile)).uri,
FileSystem.documentDirectory + 'SQLite/myDatabaseName.db'
);
return SQLite.openDatabase('myDatabaseName.db');
}