找到数据库路径是不可能的 [英] Finding database path is impossible

查看:394
本文介绍了找到数据库路径是不可能的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很新的android开发而现在我想通过一个类扩展SQLiteOpenHelper来创建数据库。我积极地确保数据存储的地方在我的Nexus 7(我使用来测试我的应用程序的设备),但是我无法找到数据库路径。

我环顾四周,其他类似的问题,所有的答案指向查找数据库中的数据/数据​​/ com.example.projet_name /数据库/数据库名称,但我没有这样的路径在我的设备。

这是什么问题可能是任何想法?或许有,我应该寻找其他的途径?

感谢您的时间。

编辑:

请从我的previous后这里找到我的code

现在我收到以下错误,当我运行应用程序。我希望这有助于以某种方式。

  8月七号至17日:28:20.130:E / libgps(486):LIBGPS:不能通信(写)与GPSD
8月7号至17号:28:20.130:E / libgps(486):IPC通信错误, /tmp/11862727/customers/Asustek/Tabletandroid/../../../proprietary/deliverables/android/gps_interface/../gps_interface/gpsi_client/GpsiClient.cpp:1178 agps_ril_update_network_state
 

解决方案

如何设置DBNAME为完整的路径:

 字符串DATABASE_NAME =/data/data/"+packageName+"db.db;
 

,或把你的分贝SD卡:

 字符串DATABASE_NAME = Environment.getExternalStorageDirectory()+的packageName +db.db;
 

通过DBPATH在code:

 公共DatabaseImplementation(上下文的背景下)
{
    超(背景下,DATABASE_NAME,空,DATABASE_VERSION);
}
 

I am quite new to android development and right now I'm trying to create a database through a class extending SQLiteOpenHelper. I am positively sure that the data is being stored somewhere on my Nexus 7 (the device I'm using to test my applications), however I cannot find the path to the database.

I've looked around for other similar questions and all the answers point to finding the database at data/data/com.example.projet_name/databases/database_name but I do not have such a path on my device.

Any ideas on what the problem might be? Or perhaps there are other paths that I should look for?

Thanks for your time.

EDITED :

Please find my code here from my previous post.

Now I am getting the following error when I run the application. I hope it helps in some way.

07-17 08:28:20.130: E/libgps(486): LIBGPS: Cannot communicate (write) with a GPSD
07-17 08:28:20.130: E/libgps(486): IPC Communication Error, /tmp/11862727/customers/Asustek/Tabletandroid/../../../proprietary/deliverables/android/gps_interface/../gps_interface/gpsi_client/GpsiClient.cpp:1178 agps_ril_update_network_state

解决方案

How about setting the dbname as full path:

String DATABASE_NAME = "/data/data/"+packageName+"db.db";

or put your db in SD card:

String DATABASE_NAME= Environment.getExternalStorageDirectory()+packageName+"db.db";

pass the dbPath in your code:

public DatabaseImplementation(Context context) 
{
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
}

这篇关于找到数据库路径是不可能的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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