我如何在 eclipse 中查看我的 sqlite 数据库结构 IDE
how can i see my sqlite database structure in eclipse IDE
我在 sqlite 数据库中创建了一个 table 我正在执行所有 CRUD 操作,但我想查看我的数据库模式。我尝试通过 eclipse IDE 的 DDMS 工具,但没有数据库。我如何才能看到我的 database.i 正在使用真实设备。请帮我。
提前致谢
在真实设备中,您无法访问 SQLite 数据库,除非您 phone 已 root.. 在虚拟设备中,但您可以访问它。但是你无法看到实际的架构。你所看到的只是一些文本文件,一旦你打开它们,你的列(数据字段)就会被制表符或其他东西分隔开。所以
How can I see my database? YOU CAN'T
在eclipse 中使用一些jar 只能访问root 的真实设备。否则,您可以从 DDMS Respective 在模拟器中播种数据库结构。要知道如何做到这一点。
Please red this to solve your problem.
你可以使用这个方法:
STEP 1:首先通过编写函数导出数据库:
public static void backupDatabase() throws IOException {
//Open your local db as the input stream
String inFileName = "/data/data/com.myapp.main/databases/MYDB";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = Environment.getExternalStorageDirectory()+"/MYDB";
//Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
output.write(buffer, 0, length);
}
//Close the streams
output.flush();
output.close();
fis.close();
}
取自Stack overflow link
然后下载 DB Browser for SQLite 并在那里打开数据库文件。DB Browser for SQLite
如果您在实施过程中发现任何困难,请对我 go.Inform 表示感谢。
我在 sqlite 数据库中创建了一个 table 我正在执行所有 CRUD 操作,但我想查看我的数据库模式。我尝试通过 eclipse IDE 的 DDMS 工具,但没有数据库。我如何才能看到我的 database.i 正在使用真实设备。请帮我。 提前致谢
在真实设备中,您无法访问 SQLite 数据库,除非您 phone 已 root.. 在虚拟设备中,但您可以访问它。但是你无法看到实际的架构。你所看到的只是一些文本文件,一旦你打开它们,你的列(数据字段)就会被制表符或其他东西分隔开。所以
How can I see my database? YOU CAN'T
在eclipse 中使用一些jar 只能访问root 的真实设备。否则,您可以从 DDMS Respective 在模拟器中播种数据库结构。要知道如何做到这一点。 Please red this to solve your problem.
你可以使用这个方法:
STEP 1:首先通过编写函数导出数据库:
public static void backupDatabase() throws IOException {
//Open your local db as the input stream
String inFileName = "/data/data/com.myapp.main/databases/MYDB";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);
String outFileName = Environment.getExternalStorageDirectory()+"/MYDB";
//Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
output.write(buffer, 0, length);
}
//Close the streams
output.flush();
output.close();
fis.close();
}
取自Stack overflow link
然后下载 DB Browser for SQLite 并在那里打开数据库文件。DB Browser for SQLite
如果您在实施过程中发现任何困难,请对我 go.Inform 表示感谢。