如何在Android虚拟设备(AVD)上手动编辑SQLite数据库?
Editing/Exporting SQLite Databases in Your AVD
Absolutely! Since this is your own test app and you already know the database path, you’ve got a couple of reliable options to modify the SQLite data—either directly in the AVD or by exporting, editing locally, and pushing it back.
Option 1: Edit Directly in the AVD via ADB Shell
This is quick if you only need to run a few SQL commands:
- Fire up your AVD and make sure your app has been launched at least once (so the database is created).
- Open your terminal/command prompt and enter the AVD shell:
adb shell - For Android 10+, you’ll need to use
run-asto access your app’s private directory (stricter scoped storage rules apply here):
For older Android versions, you can directly navigate to the database path:run-as com.your.app.package.name cd databasescd /data/data/com.your.app.package.name/databases/ - Launch the SQLite command-line tool with your database file:
sqlite3 your_database_filename.db - Now you can run standard SQL commands to modify data, like:
UPDATE your_table SET your_column = 'test_scenario_value' WHERE id = 1; - When you’re done, exit the SQLite tool and ADB shell:
.exit exit
Option 2: Export, Edit Locally, and Push Back
This is ideal for complex edits or when you want to visualize the data with a GUI tool:
- Export the database from the AVD to your local machine:
adb pull /data/data/com.your.app.package.name/databases/your_database_filename.db ./local_backup/ - Open the exported
.dbfile with a local SQLite tool (like DB Browser for SQLite or SQLiteStudio)—these tools let you easily edit tables, rows, and values via a user-friendly interface. - Once you’ve made your changes and saved the file, push it back to the AVD. Important: Close your app in the AVD first to avoid database locking issues:
adb push ./local_backup/your_database_filename.db /data/data/com.your.app.package.name/databases/ - Restart your app in the AVD, and it will load the modified database.
Key Notes
- Make sure your app is built in debug mode: Release builds restrict access to the
/data/datadirectory, so you won’t be able to modify the database this way. - Always back up the original database before making changes—better safe than sorry if something goes wrong!
- If you hit permission errors, double-check that your AVD is fully booted and your app has been installed correctly.
内容的提问来源于stack exchange,提问作者ausgeorge
相关产品推荐
相关产品推荐

