Closed. This question needs to be more focused。它当前不接受答案。
                            
                        
                    
                
                            
                                
                
                        
                            
                        
                    
                        
                            想改善这个问题吗?更新问题,使其仅通过editing this post专注于一个问题。
                        
                        3年前关闭。
                                                                                            
                
        
我看到Ionic2支持SqlStorage,并且仅用于创建表,我不知道如何在SqlStorage中使用预填充的sqlite db。
有什么可以帮助我的吗?
提前致谢!!

最佳答案

创建存储时,您可以传递一个选项对象

let storage = new Storage(SqlStorage, options);


SqlStorage服务支持以下选项:

let options = {
  name: '__ionicstorage',              // the name of the database
  backupFlag: SqlStorage.BACKUP_LOCAL, // where to store the file
  existingDatabase: false              // load this as an existing database
};


因此,应将existingDatabase设置为true,确保name与您的数据库匹配,然后将backupFlag设置为指向正确的位置。

相关文档在这里:
http://ionicframework.com/docs/v2/api/platform/storage/SqlStorage/

来源也很容易理解:https://github.com/driftyco/ionic/blob/2.0/ionic/platform/storage/sql.ts

09-04 13:10