mysql查询模拟器,如何查看Android的SQLLite模拟器上的数据库

I've looked at answers to previous questions on this topic, but can't seem to get any of them to work. I am developing in Eclipse, and running the app on an emulator.

It seems like the simplest approach is to use the adb shell in conjunction with the sqlite3 command. With adb I can see the emulator device. When I start the adb shell, I see a directory which is where I would expect to find the database:

/data/data/com.example.myfirstapp/databases/ (where com.example.myfirstapp is the package name of the app)

However, there are no .db files in that directory. There is a file with the same name as the database the app created, but it does not have the .db extension.

(I'm pretty sure I am seeing the file system of the emulated device because it does have the directory for my application).

UPDATE

After going through all the responses, and accessing the database via adb/sqlite3 and also using DDMD/Sqlite browser, I realized I made a "newbie" mistake in the code:

public class MessageOpenHelper extends SQLiteOpenHelper {

public static final String DATABASE_NAME = "MyFirstApp.db";

public static final String MESSAGE_COLUMN = "message";

public static final String MESSAGE_TABLE_NAME = "messages";

private static final String MESSAGE_TABLE_CREATE = String.format("create table %s (%s TEXT);", MESSAGE_TABLE_NAME, MESSAGE_COLUMN);

public MessageOpenHelper(Context context) {

super(context, DATABASE_NAME, null, DATABASE_VERSION);

}

By convention, the database name should include the .db extension. Although it works fine without it, the Sqlite browser for Eclipse won't recognize the file. Hopefully other neophytes like me won't make the same mistake.

解决方案

You mentioned you are using Eclipse ... You can go in DDMS perspective, select the db file and view in Sqllite Browser .. as shown below...

dH5KG.png

EDIT:-

Forgot to mentioned we require to add the plugin here...

Follow the link here

Steps:-

Download the jar file

Add the jar file in your eclipse/dropins/ folder

Restart Eclipse.. you will notice the icon in DDMS perspective..

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值