You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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-as to access your app’s private directory (stricter scoped storage rules apply here):
    run-as com.your.app.package.name
    cd databases
    
    For older Android versions, you can directly navigate to the database path:
    cd /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 .db file 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/data directory, 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 07:42:03