Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. (/root/data or something I guess). I have viewed the DB and performed some manipulations, it helps in development.

Now, I am using AsyncStorage API of react native. 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. As my chrome on linux is a bad boy(Any Help would be appreciated)!

like image 277
bozzmob Avatar asked Dec 19 '15 14:12

bozzmob


3 Answers

You can follow below steps

  1. Run your apk in debug mode in your device and connect your device to your system

  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/

you can get package name from your AndroidManifest.xml file

  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

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 pull /sdcard/Rkstorage

  1. Now Install Firefox SQLite Manager: https://addons.mozilla.org/en-US/firefox/addon/sqlite-manager/

  2. Open Firefox SQLite Manager from Tools->SQLite Manager

  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.

Thanks.

like image 156
Satish Sojitra Avatar answered Nov 17 '22 16:11

Satish Sojitra


React Native on Android actually uses SQLite to back up the AsyncStorage API. The database file is /data/data/<your_app>/databases/RKStorage on your device/emulator. Keys and values are stored in a table named catalystLocalStorage.

like image 29
fagerbua Avatar answered Nov 17 '22 15:11

fagerbua


Use sqlite3 /data/data/<your_app>/databases/RKStorage .dump to see entire content. And use cp /data/data/<your_app>/databases/RKStorage /mnt/sdcard/ and use adb pull/push to copy it to your local device.

like image 2
Ender Avatar answered Nov 17 '22 16:11

Ender