查看SQLite数据库的设备在Android的工作室 [英] View SQLite database on device in Android Studio

查看:209
本文介绍了查看SQLite数据库的设备在Android的工作室的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Android Studio的最新版本。当我在模拟器上运行我的应用程序,我能够一路过关斩将,以查看我的数据库:

工具 - > Android设备监视器 - >单击该仿真器在左面板 - >文件浏览器 - >数据 - >数据 - > com.project名

但在设备上运行我的应用程序时,该选项不可用。

我已经检查了相关的问题:

  1. Android的? - 查看设备上SQLite数据库的最投在这里的答案建议复制数据库到SD卡,它甚至为Eclipse。
  2. 在Android设备
  3. 访问SQLite数据库

而这些问题是从2011年和2010年。 是否有任何插件,我可以用或其他外部工具?

解决方案

通过ADB壳连接到SQLITE3

我还没有发现任何办法做到这一点在Android的工作室,但我获得的每一次拉动文件中的分贝与远程shell来代替。

找到所有的信息在这里: http://developer.android.com/tool​​s/help/adb.html#sqlite

1 - 转到您的平台,工具,文件夹中的命令提示符

2 - 输入命令 ADB设备来让你的设备列表

  C:\的Andr​​oid \ ADT-束窗口-x86_64的\ SDK \平台工具> ADB设备
设备名单附后
模拟器-XXXX设备
 

3的壳连接到设备:

  C:\的Andr​​oid \ ADT-束窗口-x86_64的\ SDK \平台工具>亚行-s模拟器-XXXX壳
 

4-导航到包含您的数据库文件的文件夹:

  CD数据/数据​​/<您-包名称> /数据库/
 

5运行sqlite3的连接到你的数据库:

  sqlite3的<您-DB-名称> .db的
 

6运行sqlite3的命令,你喜欢的,例如:

  SELECT * FROM表1 WHERE ...;
 

  

注意:查找更多下面的命令来运行

的S​​QLite的cheatsheet

有几步看到一个SQLite数据库中的表:

  1. 在列出数据库中的表:

      .tables
     

  2. 如何列出表格的外观:

      .schema表名
     

  3. 打印整个表:

      SELECT * FROM表名;
     

  4. 列出所有可用的SQLite提示的命令:

     。帮助
     

来源:,以便回答。

I am using the latest version of Android Studio. When I run my app on the emulator, I am able to view my database by going through:

tools -> Android Device Monitor -> clicking on the emulator in the left panel -> file explorer -> data -> data -> com.project-name

But this option isn't available when running my app on a device.

I have checked related questions:

  1. Android - viewing SQLite databases on device? The most voted answer here suggests copying the database to SDcard, and it's even for eclipse.
  2. Access sqlite database on android device

and these questions are from 2011 and 2010. Are there any plugins I can use or other external tools?

解决方案

Connect to Sqlite3 via ADB Shell

I haven't found any way to do that in Android Studio, but I access the db with a remote shell instead of pulling the file each time.

Find all info here: http://developer.android.com/tools/help/adb.html#sqlite

1- Go to your platform-tools folder in a command prompt

2- Enter the command adb devices to get the list of your devices

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb devices
List of devices attached
emulator-xxxx   device

3- Connect a shell to your device:

C:\Android\adt-bundle-windows-x86_64\sdk\platform-tools>adb -s emulator-xxxx shell

4- Navigate to the folder containing your db file:

cd data/data/<your-package-name>/databases/

5- run sqlite3 to connect to your db:

sqlite3 <your-db-name>.db

6- run sqlite3 commands that you like eg:

Select * from table1 where ...;

Note: Find more commands to run below.

SQLite cheatsheet

There are a few steps to see the tables in an SQLite database:

  1. List the tables in your database:

    .tables
    

  2. List how the table looks:

    .schema tablename
    

  3. Print the entire table:

    SELECT * FROM tablename;
    

  4. List all of the available SQLite prompt commands:

    .help
    

Source : This SO answer..

这篇关于查看SQLite数据库的设备在Android的工作室的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆