[英]read database from web using SQLiteDatabase.openDatabase()
my android application needs to read from a database on the web and I have just no idea how am I supposed to do it. 我的Android应用程序需要从网络上的数据库中读取内容,但我不知道该怎么做。
I tried the following code: 我尝试了以下代码:
SQLiteDatabase.CursorFactory cf = new SQLiteDatabase.CursorFactory() {
@Override
public Cursor newCursor(SQLiteDatabase db, SQLiteCursorDriver masterQuery,
String editTable, SQLiteQuery query) {
// TODO Auto-generated method stub
return null;
}
};
SQLiteDatabase db =SQLiteDatabase.openDatabase("http://dakatora.co.il/locallhost", cf, SQLiteDatabase.OPEN_READONLY);
but it throws an exception 但它抛出一个异常
can someone please help me? 有人可以帮帮我吗?
You can not access database directly from an android device (without a lot of hard work and "hackish" ways). 您无法直接从android设备访问数据库(没有很多辛苦和“骇客”的方式)。 You should never use a direct connection to a outside database.
您永远不应使用与外部数据库的直接连接。 Using a web service is aa lot safer.
使用Web服务要安全得多。
Also you could try something like this: Interacting with external SQLite databases from Android. 您也可以尝试如下操作: 与Android中的外部SQLite数据库进行交互。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.