无法在Android上的React Native中打开sqlite数据库

时间:2018-10-29 15:51:50

标签: android reactjs sqlite native

我正在努力弄清为什么我无法在从iOS上的Android平台上的服务器上下载的sqlite db上执行sql命令的情况。

以下是我不断收到的错误: enter image description here

我记录了步骤,并将尝试提供尽可能多的详细信息。但是基本上我是使用RNFetchBlob从服务器下载的,然后使用RNFS检查目标路径是否存在,删除是否存在。然后将db blob写入磁盘并使用react-native-sqlite-storage打开。所有这些都可以在iOS上使用,并且在Android上也可以使用。

Blob downloads and exists here:  /data/user/0/com.test.app/files/RNFetchBlob-blobs/blob-fsd7ows38p9o1fxwulprt
Blob moved to /data/user/0/com.test.app/files/PriceBook.db using RNFS.MoveFile
installPriceBookDatabase  /data/user/0/com.test.app/files/PriceBook.db
Checking to make sure DB file exists before opening, does it? true
OPEN database: PriceBook.db
DB successfully installed 

我可以确认数据库位于/data/user/0/com.test.app/files/PriceBook.db的位置,并可以使用DB Browser for SQLite在我的Mac上打开它。

旁注:createFromLocation似乎也不是答案,因为我已经尝试过并得到以下错误:

OPEN database: PriceBook.db failed, aborting any pending transactions
Error installing DB Error: Could not open database

注释2:在全新安装中,如果打开数据库并在收到SELECT * FROM sqlite_master消息后执行DB successfully installed,则会得到以下信息:

enter image description here

0 个答案:

没有答案