capacitor-community / sqlite

⚡Capacitor plugin for native & electron SQLite databases.
MIT License
492 stars 116 forks source link

Connect to SQLite database on external storage directory using capacitor sqlite plugin #557

Closed manueljhu closed 4 months ago

manueljhu commented 4 months ago

Exist any way to connect to database ubicated on external directory on android using the capacitor sqlite plugin?

The current path where are the sqlite seems like: file:///data/user/0/io.ionic.starter/files/databasename.db

I have gotten it to work by doing the following:

1-Using filesystem plugin to copy the database from external to internal storage 2-Using then function moveDatabasesAndAddSuffix({ folderPath: Directory.External, dbNameList: [this.databasename] }); 3-Using the function createConnection(dbName, encrypted, mode, version, readonly);

Doing this steps works but i would like to know if is possible do it directly on the directory.EXTERNAL.

Versions: Ionic: 7.2.0 Capacitor: 6.0.0 Node: v20.11.1

Plugins: @capacitor-community/sqlite@5.7.3-3 @capacitor/app@6.0.0 @capacitor/filesystem@6.0.0 @capacitor/haptics@6.0.0 @capacitor/keyboard@6.0.0 @capacitor/network@6.0.0 @capacitor/splash-screen@6.0.0 @capacitor/status-bar@6.0.0

jepiqueau commented 4 months ago

@manueljhu there is no way to use directly a database from external storage. The method you have use the database from external to internal storage is correct and now you can connect to the database in the internal storage and do whatever query on it

manueljhu commented 4 months ago

Ok, thank you so much!! Very quickly response