Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
how to export realm database, work on Android 5.0+
#!/bin/bash
ADB_PATH="/Users/lee/Library/Android/sdk/platform-tools"
PACKAGE_NAME="com.yourcompany.app"
DB_NAME="default.realm"
DESTINATION_PATH="/Users/lee/Downloads/${DB_NAME}"
NOT_PRESENT="List of devices attached"
ADB_FOUND=`${ADB_PATH}/adb devices | tail -2 | head -1 | cut -f 1 | sed 's/ *$//g'`
if [[ ${ADB_FOUND} == ${NOT_PRESENT} ]]; then
echo "Make sure a device is connected"
else
${ADB_PATH}/adb exec-out run-as ${PACKAGE_NAME} cat files/${DB_NAME} > ${DESTINATION_PATH}
echo "Database exported to ${DESTINATION_PATH}"
fi
@DaveChambers

This comment has been minimized.

Copy link

DaveChambers commented Jul 29, 2018

Nice work!

@mcmatan

This comment has been minimized.

Copy link

mcmatan commented Aug 16, 2018

Wow. King.

@bfichter

This comment has been minimized.

Copy link

bfichter commented Oct 3, 2018

Super helpful, thanks!

@danielbas

This comment has been minimized.

Copy link

danielbas commented Nov 14, 2018

This is very helpful, thank you!

@locpv-ibl

This comment has been minimized.

Copy link

locpv-ibl commented Feb 22, 2019

Nice query but this is only for debuggable package. Best android practices do say that "Your minifest file should have set debug to false". That will probably prevent from this query!

@ronaldondantas

This comment has been minimized.

Copy link

ronaldondantas commented Jul 10, 2019

Awesome! Thanks.

@wagnerpaz

This comment has been minimized.

Copy link

wagnerpaz commented Mar 23, 2020

Many thanks! It works like a charm!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.