Sunday, August 12, 2018

Migrate SQLite Database from Titanium to Ionic in iOS App

Leave a Comment

I am updating the app store with an Ionic version of an old Titanium/Alloy app. The Alloy sql.js sync adapter has:

var ALLOY_DB_DEFAULT = "_alloy_"; 

A backup of a phone running the old app made with iExplorer contains the file:

(App)/Library/Private Documents/_alloy_.sql 

Can I access this database like this in Ionic?

    db = window.sqlitePlugin.openDatabase({       name: '_alloy_.sql',       location: 1,     }) 

I am trying to run the old app and test the migration, but Titanium Studio is very difficult to get going at this point. My migration works well if I just stuff the old _alloy_.sql file into the iOS Simulator at:

~/Library/Developer/CoreSimulator/Devices/<id>/data/Containers/Data/Application/<id>/Library/ 

1 Answers

Answers 1

Old thread response, hopefully someone still finds the answer useful.

We've solved our own bounty.

The database is stored in the IOS Library in the 'Private Data' directory with the filename _alloy_.sql

let tiAppOptions = {name: "Private Documents/_alloy_.sql", iosDatabaseLocation: 'Library'};  this.sqlite.create(tiAppOptions).then((db: SQLiteObject) => {     db.executeSql("SELECT * from table_name", {}).then((data) => {         //do something with the data.     }); }, err => {    console.log(err); }); 

Android is stored in the 'default' location with filename _alloy_.sql

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment