react-native-sqlite-storage
react-native-sqlite-storage copied to clipboard
How to find Database file location in React native app - Andriod
I have created and stored values in the database. I just want to know the db file size & view the contents of the database. In case of native Android app, I can view the db file through Andriod device monitor in Android Studio. Can anyone help me in finding the location of the Sqlite database in React native andriod?
Would really like to know how to do this as well. There's nothing in /Android/data/com.whatever.appname/
Did you guys find out where the .db is?
I want to know too! -_-
You need to have Root access (not that difficult with an emulator) and access /data/data/{your.app.folder}/databases, I don't know if there's another way but that worked for me
You don't need to have a root access if you the version of the App is debug. use
run-as your.package
The database is located in the databases folder. If you have an access to the release keychain you could even replace the release version of the app by the debug version signed with the release key and get needed access.
i also want to know where is database file in react native. sqlite
@dryganets , how to use this command in cmd .. ?? run-as your.package
adb shell runs the shell
in shell run:
run-as package-name
It automatically redirect you to the application folder.
Runls databases to output the list of files.
if you want to copy the file to sdcard
cat filename.db > /sdcard/filename.db
exit the shell session
and run
adb pull /sdcard/filename.db
The database file name is exact to the name you passed in the js code.
This code help me here to get db :
adb -d shell "run-as com.dautechnology.abdimuna.smartparking cat /data/data/<myAppPackageName>/databases/<databaseFileName> > /sdcard/<databaseFileName>"
The above command will store file to /sdcard You can verify the file by adb shell ls sdcard/ Then exit from adb shell by typing exit
https://stackoverflow.com/questions/34372057/where-is-asyncstorage-data-physically-located-on-android-devices/43781842#43781842
Is there away to get the location via react native?
I need to find the location, upload the sqlite file to remote server for bug report purposes thanks.
Created separate posts for how to delete the database and how to check DB file location on user phone.
https://infinitbility.com/how-to-delete-sqlite-database-in-android-react-native
please i want to know, where i find location .sqlite file. with react-native
please i want to know, where i find location .sqlite file. with react-native
You get sqlite_db_name.db file on your Android/data/com.projectname/ databases folder.
You can also check using rn-fetch-blob
import RNFetchBlob from 'rn-fetch-blob';
const dirs = RNFetchBlob.fs.dirs;
RNFetchBlob.fs.ls(dirs.MainBundleDir + '/databases').then((files) => {
console.log(files)
});
Code Snippet from below documentation
https://infinitbility.com/how-to-delete-sqlite-database-in-android-react-native
When Launch succeeded: In Device File Explorer> data> data> com.nameofyourapp> databases You can also click on the bottom tab of android studio 'Database inspector' to see the database changes in real time.
@CarolinaPerezFlores Thanks. Yes we can export this db from here. and also can open that db file in sqlbrowser software (https://sqlitebrowser.org/ )

@alan-la-chen-478 Hey, have you found a solution? I also need to get the db file and send it to the server, but I cannot find a way to do this. Could you please share your solution?
@pigpudle
For me, my app only support android, and this is what i'm using to send debug data to my server. I'm not too sure about ios and where they store it.
export const sendDbReport = async state => {
let response = await RNFetchBlob.fetch(
'POST',
`${appConfig.api_domain}/debug-reports`,
{
'Content-Type': 'multipart/form-data',
},
[
{name: 'db', filename: 'database.sqlite', data: RNFetchBlob.wrap(await getDbFilePath())},
{name: 'info', data: JSON.stringify(await getDebugInfo(state))},
],
);
return response.json();
};
export const getDbFilePath = async () => {
let bundleId = await DeviceInfo.getBundleId();
return `/data/data/${bundleId}/databases/${dbName}`;
};
// dbName is what you put for SQLite.openDatabase args