Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android - Access to online Database SQlite

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);

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.

like image 613
Oneiros Avatar asked Oct 13 '22 18:10

Oneiros


1 Answers

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

  • someone has direct access to your datasource and can read, manipulate or destroy the data
  • abstraction; you can control the way in which the data is sent and how it's represented. Should the database tables/objects change, you'd only have to change the web service instead of force an update (in some cases)
  • JSON interaction is very well supported on Android out of the box, whereas JDBC isn't (for previously documented reasons)

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

like image 78
Alex Avatar answered Nov 05 '22 01:11

Alex