如何解决在React Native中如何在sqlite3中创建数据库
我在此链接https://github.com/andpor/react-native-sqlite-storage中浏览了所有详细信息。我对他们的文档感到困惑。
...
1.SQLite.openDatabase({name : "testDB",createFromLocation : 1},okCallback,errorCallback);
// default - if your folder is called www and data file is named the same as the dbName - testDB in this example
2.SQLite.openDatabase({name : "testDB",createFromLocation : "~data/mydbfile.sqlite"},errorCallback);
// if your folder is called data rather than www or your filename does not match the name of the db
3.SQLite.openDatabase({name : "testDB",createFromLocation : "/data/mydbfile.sqlite"},errorCallback);
// if your folder is not in app bundle but in app sandbox i.e. downloaded from some remote location.
...
以上陈述将做什么?
它会创建数据库还是会打开www
或asset
文件夹中的数据库?
我可以在所需的任何文件夹中创建数据库吗?
没有,我在此找到明确的答案。这就是为什么我在stackoverflow中问这个问题。
解决方法
有时候我也遇到过同样的问题。您需要根据文档进行所有设置。之后,如果您使用database.db
提供createFromLocation
的位置,则必须创建一个空的数据库文件并将其手动粘贴到资产中,如果您不想手动创建,则只需使用SQLite.openDatabase({name : "testDB"})
会创建自己的数据库作为提供的名称。希望这会对您有所帮助,请告诉我是否可行。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。