简体   繁体   English

AsyncStorage 数据在 Android 设备上的物理位置在哪里?

[英]Where is AsyncStorage Data Physically Located on Android Devices?

Maybe the title isn't very clear.可能标题不是很清楚。 Here is what I mean/need to know-这就是我的意思/需要知道的-

If I use SQLite for some data storing purpose on Android app, I can see the DB created in my phone.如果我在 Android 应用程序上将 SQLite 用于某些数据存储目的,我可以看到在我的手机中创建的数据库。 (/root/data or something I guess). (/root/data 或我猜的其他东西)。 I have viewed the DB and performed some manipulations, it helps in development.我查看了数据库并执行了一些操作,它有助于开发。

Now, I am using AsyncStorage API of react native.现在,我正在使用 React Native 的 AsyncStorage API。 There is some problem in my code, I am not able to get the stored data from the store.我的代码有问题,我无法从商店获取存储的数据。 Not sure what I am doing wrong.不确定我做错了什么。

So, to see what's wrong, is there a way to view the list of Objects that are being stored on the phone?那么,要看看哪里出了问题,有没有办法查看手机上存储的对象列表? If so where?如果是哪里? And how do I view it?我如何查看它?

PS: I am debugging my React Native app using Android Studio's logs. PS:我正在使用 Android Studio 的日志调试我的 React Native 应用程序。 As my chrome on linux is a bad boy (Any Help would be appreciated)!因为我在 linux 上的 chrome 是个坏孩子(任何帮助将不胜感激)!

You can follow below steps您可以按照以下步骤

  1. Run your apk in debug mode in your device and connect your device to your system在您的设备中以调试模式运行您的 apk 并将您的设备连接到您的系统

  2. Open command prompt.打开命令提示符。

  3. To get list of databases related to your application use below command要获取与您的应用程序相关的数据库列表,请使用以下命令

adb -d shell "run-as om.yourpackage_name ls /data/data/com.yourpackage_name/databases/ adb -d shell "run-as om.yourpackage_name ls /data/data/com.yourpackage_name/databases/

you can get package name from your AndroidManifest.xml file您可以从 AndroidManifest.xml 文件中获取包名称

  1. Now you have database name in above list then copy that database to sdcard in your phone using following command for react native it will be RKStorage现在你在上面的列表中有数据库名称,然后使用以下命令将该数据库复制到手机中的 sdcard 以响应本机,它将是 RKStorage

adb -d shell "run-as com.yourpackage cp /data/data/com.your_package/databases/RKStorage /sdcard/Rkstorage" adb -d shell "run-as com.yourpackage cp /data/data/com.your_package/databases/RKStorage /sdcard/Rkstorage"

  1. Now use below command to pull above copied database from your device to your system.现在使用下面的命令将上面复制的数据库从您的设备拉到您的系统。 below command will copy database to directory where adb.exe exists.下面的命令会将数据库复制到 adb.exe 所在的目录。

adb pull /sdcard/Rkstorage adb pull /sdcard/Rkstorage

  1. Now Install Firefox SQLite Manager: https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/现在安装 Firefox SQLite 管理器: https ://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

  2. Open Firefox SQLite Manager from Tools->SQLite Manager从工具->SQLite 管理器打开 Firefox SQLite 管理器

  3. In SQLite Manager go to Database->Connect Database and "open file" window will open there you select All files at bottom of your window and navigate where your database copied.在 SQLite 管理器中,转到数据库-> 连接数据库,“打开文件”窗口将在那里打开,您选择窗口底部的所有文件并导航到数据库复制的位置。

Thanks.谢谢。

React Native on Android actually uses SQLite to back up the AsyncStorage API. Android 上的 React Native 实际上使用 SQLite 来备份 AsyncStorage API。 The database file is /data/data/<your_app>/databases/RKStorage on your device/emulator.数据库文件是/data/data/<your_app>/databases/RKStorage在你的设备/模拟器上。 Keys and values are stored in a table named catalystLocalStorage .键和值存储在名为catalystLocalStorage的表中。

Use sqlite3 /data/data/<your_app>/databases/RKStorage.dump to see entire content.使用sqlite3 /data/data/<your_app>/databases/RKStorage.dump查看全部内容。 And use cp /data/data/<your_app>/databases/RKStorage /mnt/sdcard/ and use adb pull/push to copy it to your local device.并使用cp /data/data/<your_app>/databases/RKStorage /mnt/sdcard/并使用adb pull/push其复制到本地设备。

If you are working on react-native and using react-native-sqlite-storage , then you can find the DB file <aap-name>/android/app/src/main/assets/www/<db-named-file> for Android .如果您正在使用react-native并使用react-native-sqlite-storage ,那么您可以找到数据库文件<aap-name>/android/app/src/main/assets/www/<db-named-file>对于Android And for iOS , DB file location is <app-name>/ios/<app-name>/www/<db-named-file> .对于iOS ,数据库文件位置是<app-name>/ios/<app-name>/www/<db-named-file>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM