Reputation: 485
I am building an upgrade for an old app build using @ionic-native/sqlite 4 to store its local data in an sqlite database.
My new app uses @capacitor-community/sqlite.
The old creates its database like this:
this.sqlite.create({
name: 'my.db',
location: 'default'
})
I've put the old app into an emulator and I can see it indeed creates the file under this path: /data/data/my-app-id/databases/my.db
I can see and access this file in the device file browser of Android Studio.
While it does this it logs that it opened an sqlite database at /data/user/0/my-app-id/databases/my.db
I am unsure what the difference between these paths is.
The new app is supposed to open this old file to import old user data. This however does not work. My expecation is that after installing the new version of the app as an update it should be able to access the file at the given location.
I try to do this using the capacitor sqlite plugin with getNCCOnnection.
However trying any of these fails, telling me the file does not exist:
const oldDBPath = '/data/user/0/my-app-id/databases/my.db';
const oldConnection = await this.sqliteService.createNCConnection(oldDBPath, 1);
const oldDBPath = '/data/data/my-app-id/databases/my.db';
const oldConnection = await this.sqliteService.createNCConnection(oldDBPath, 1);
const oldDBPath = 'databases/my.db';
const oldConnection = await this.sqliteService.createNCConnection(oldDBPath, 1);
Why?
I have also tried to access the locations using the capacitor filesystem plugin, but they tell me the directory does not exist.
Upvotes: 1
Views: 492
Reputation: 485
Turns out I had some error in the path name I created in my code, which is why the file was not found. Oops
Upvotes: 1