LoginSignup
0
3

More than 5 years have passed since last update.

GradleでAndroid端末のSQLite DBをpullする

Posted at

やりたいこと

アプリで使ってるSQLiteファイルをGradleのコマンドでpullしたい

方法

  1. 以下のスクリプトをapp/build.gradleにペースト
  2. emu/pkg/dbを適切なものに書き換える
  3. ./gradlew pullDbを実行。
task pullDb(type: Exec) {
    def devId = "" // デバイスID、adb devicesで確認できる
    def appId = "" // 自分のアプリケーションID
    def db    = "" // SQLite DBのファイル名
    def adb   = android.adbExecutable.absolutePath
    commandLine "$adb", "-s", $devId, "shell", "run-as $appId cp databases/$db /sdcard/$db"
    commandLine "$adb", "-s", $devId, "pull", "/sdcard/$db", "."
}
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3