如何使用react-native获取获取数据库的SQLite数据库文件路径 [英] How to get SQLite database file path for get Database using react-native

查看:198
本文介绍了如何使用react-native获取获取数据库的SQLite数据库文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 react-native-sqlite-storage 用于数据库https://github.com/andpor/react-native-sqlite-storage

现在我在 .../www/文件夹中为 android 和

Now i have pre-populated-sqlite-database in .../www/ folder for both android & ios.

现在插入一些带有查询的数据 &在应用程序中获得它的正确输出.但是现在我从/www 文件夹中删除了数据库,但它的结果仍然在应用程序中.所以我认为它创建了它的副本数据库.

Now insert some data with query & get proper output of it in app. But now im delete database from /www folder but still its results are get in app. SO i think its create copy database of it.

我如何为 android 和 android 的这个副本数据库文件获取正确的数据库路径react-native 中的 ios

how im get proper database path for this copy database file for both android & ios in react-native

推荐答案

当您部署应用程序(或在模拟器中使用)时,数据库会被复制到平台,并且与 www/文件夹不同.如果您想从应用中删除数据

When you deploy an app (or use in emulator), the database is copied to the platform and isn't the same as www/ folder. If you want to remove data from app

要么卸载再安装(它会再次从www复制)

Either uninstall and install (it will copy again from www)

清除应用程序数据(这将清除所有存储并使应用程序与最初安装的一样)

Clear Application Data (that will clean all storage and make app as originally installed)

如果你渴望找到路径(虽然我想不出用例),你可以运行 make use of package like https://www.npmjs.com/package/react-native-fs 并在 App.js 中运行代码以查找当前目录和 console.log.

If you're keen to find path (though I couldn't think of a usecase), You can run make use of package like https://www.npmjs.com/package/react-native-fs and run code within App.js to find current directory and console.log it.

这篇关于如何使用react-native获取获取数据库的SQLite数据库文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆