Categories: AndroidMobility

Android – ADB Shell Batch Scripting – Automate SQLite Database Copy

This is a quick blog to represent tips on how one could run multiple adb shell commands as part of one windows batch script or automate SQLite database copy to local filesystem.

Say, you have got to copy the SQLite database from within your app to your local filesystem. The commands could be found on one of my earlier blog: http://vitalflux.com/ionic-how-to-copy-sqlite-database/

Copy following commands in a text file, say, commands.txt

  • run-as package-name-of-the-app
  • chmod 666 databases/database_name
  • exit
  • cp /data/data/package-name-of-app/databases/database_name /sdcard/
  • run-as package-name-of-the-app
  • chmod 600 databases/database_name
  • exit
  • exit

Write following set of commands in another batch script (.bat file) and name it as, say, adb.bat.

  • del database_name
  • cmd /c adb shell < commands.txt
  • cmd /c adb pull /sdcard/database_name .

Go to command prompt and execute the batch script, adb.bat. That is it. You shall have databases copied on to your local filesystem.

 

Ajitesh Kumar

I have been recently working in the area of Data analytics including Data Science and Machine Learning / Deep Learning. I am also passionate about different technologies including programming languages such as Java/JEE, Javascript, Python, R, Julia, etc, and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data, etc. For latest updates and blogs, follow us on Twitter. I would love to connect with you on Linkedin. Check out my latest book titled as First Principles Thinking: Building winning products using first principles thinking. Check out my other blog, Revive-n-Thrive.com

Share
Published by
Ajitesh Kumar
Tags: android

Recent Posts

Logistic Regression in Machine Learning: Python Example

Last updated: 26th April, 2024 In this blog post, we will discuss the logistic regression…

19 hours ago

MSE vs RMSE vs MAE vs MAPE vs R-Squared: When to Use?

Last updated: 22nd April, 2024 As data scientists, we navigate a sea of metrics to…

2 days ago

Gradient Descent in Machine Learning: Python Examples

Last updated: 22nd April, 2024 This post will teach you about the gradient descent algorithm…

5 days ago

Loss Function vs Cost Function vs Objective Function: Examples

Last updated: 19th April, 2024 Among the terminologies used in training machine learning models, the…

1 week ago

Model Parallelism vs Data Parallelism: Examples

Last updated: 19th April, 2024 Model parallelism and data parallelism are two strategies used to…

1 week ago

Model Complexity & Overfitting in Machine Learning: How to Reduce

Last updated: 4th April, 2024 In machine learning, model complexity, and overfitting are related in…

2 weeks ago