Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace app SQLite database using ADB

I'm trying to replace the database of my app with ADB, on a rooted device.

I follow these steps:

  1. $adb shell
  2. run-as my.app.package
  3. cd databases
  4. rm my_database.db
  5. chmod 777 .
  6. exit
  7. exit
  8. $adb push my_database.db /data/data/my.app.package/databases/my_database.db

The new database is copied successfully.

But when I launch my app again, it seems that the new database is deleted and created again. Why?

Thanks.

like image 852
Héctor Avatar asked Nov 10 '22 09:11

Héctor


1 Answers

I don't know exactly why but it is working now. I followed this steps:

  1. Open app (in my app, the database is created in main activity)
  2. Follow the steps mentioned in the question with the app openned
  3. Close app and remove it from memory
  4. Reopen the app

Both databases versions are the same and I have no code in onUpgrade method.

like image 76
Héctor Avatar answered Nov 15 '22 07:11

Héctor