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 DaveChambers commented Jul 29, 2018

Nice work!

@mcmatan

This comment has been minimized.

Copy link

@mcmatan mcmatan commented Aug 16, 2018

Wow. King.

@bfichter

This comment has been minimized.

Copy link

@bfichter bfichter commented Oct 3, 2018

Super helpful, thanks!

@danielbas

This comment has been minimized.

Copy link

@danielbas danielbas commented Nov 14, 2018

This is very helpful, thank you!

@locpv-ibl

This comment has been minimized.

Copy link

@locpv-ibl 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 ronaldondantas commented Jul 10, 2019

Awesome! Thanks.

@wagnerpaz

This comment has been minimized.

Copy link

@wagnerpaz wagnerpaz commented Mar 23, 2020

Many thanks! It works like a charm!

@Jeaan2

This comment has been minimized.

Copy link

@Jeaan2 Jeaan2 commented Aug 17, 2020

Thank you, man! It helped a lot!

@tejassonar

This comment has been minimized.

Copy link

@tejassonar tejassonar commented Dec 10, 2020

Thanks a lot!!!

@sirmong

This comment has been minimized.

Copy link

@sirmong sirmong commented Dec 16, 2020

Awesome! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment