Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script para exportar una base de datos realm
#!/bin/sh
#Ruta absoluta hasta la carpeta platform-tools del sdk de Android. Ej: /Users/josemaria/Library/Android/sdk/platform-tools
ADB_PATH=""
#Paquete de la app. Ej: com.jmperezra.appname
PACKAGE_NAME=""
#Nombre de la base de datos Realm. Ej: default.realm
DB_NAME=""
#Ruta absoluta del destino del fichero .realm. Ej: /Users/josemaria/proyecto/AppName/db/
DESTINATION_PATH=""
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 shell "run-as ${PACKAGE_NAME} chmod 666 /data/data/${PACKAGE_NAME}/files/${DB_NAME}
cp /data/data/${PACKAGE_NAME}/files/${DB_NAME} /sdcard/
exit"
${ADB_PATH}/adb pull "/sdcard/${DB_NAME}" "${DESTINATION_PATH}"
echo "Database exported to ${DESTINATION_PATH}${DB_NAME}"
fi
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.