Android的 - 访问在线数据库SQLite的 [英] Android - Access to online Database SQlite

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

问题描述

我需要打开,读取和Android应用程序。照片我知道网址,用户名和密码,将项目插入一个在线SQLite数据库。在JavaSE的我会做到以下几点:

I need to open, read and insert items into an online SQLite database from an Android app.
I know url, username and password. In JavaSE i would do the following:

Class.forName("com.mysql.jdbc.Driver");
Connection dbConnection = DriverManager.getConnection(URL, USER, PASSWORD);

我看,我不能这样做在Android中,因为没有一个JDBC驱动程序(有一个SQLite.JDBCDriver,但它不记录,不推荐)。
因此,这是最简单的方法是什么?我问谷歌,但它看起来像他要么不知道。

I read that I can't do this in Android because there is not a JDBC Driver (there is a "SQLite.JDBCDriver" but it is not documented and not recommended).
So which is the easiest way? I asked to Google but it looks like he either doesn't know.

推荐答案

您应该通过一个中介暴露你的数据源是这样,如Web服务,至少有以下原因:

You should expose your datasource like this via an intermediary such as a Web Service for at least the following reasons:

  • 有人直接访问您的数据源,可以读取,操纵或破坏数据
  • 抽象;可以控制其中的数据被发送的方式,它是如何重新presented。如果数据库表/对象的改变,你只需要更改Web服务,而不是强制进行更新(在某些情况下)
  • 在JSON交互具有很好的支持在Android开箱即用,而JDBC是不是(为previously记录的原因)

我敢肯定有很多的原因比较多,但以上是最prevalent在我的脑海里。

I'm sure there are plenty of more reasons, but the above are the most prevalent in my mind.

这篇关于Android的 - 访问在线数据库SQLite的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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