user3353094
user3353094

Reputation: 1

Android cannot connect directly with a Postgres database, and cannot use JDBC connections

I have this problem that my Android app cannot connect directly with a Postgres databse and cannot use JDBC connections. I've browsed the web a bit and some people say, that the best way to deal with this is to run a web service. I'm absolutely lost on how to tackle this problem. Should I build an extension of some sort or... ? Thanks in advance for the help.

Upvotes: 0

Views: 7318

Answers (2)

ofnowhere
ofnowhere

Reputation: 1135

You can never have a direct access to a database which is on a server. For this you need to run some server side code and use JSON to interact your app with server

This tutorial might be of help to you:Connect android with PHP Mysql

And instead of connecting to MYSQL you can connect to PostgreSQL with the help of these docs:

PHP with PostgreSQL

Upvotes: 0

Craig Ringer
Craig Ringer

Reputation: 324395

It's possible to use JDBC with pgJDBC on newer Android versions, but not a good idea.

See JDBC vs Web Service for Android and Driver JDBC PostgreSQL with Android for why.

Basically, if you're on a device with potentially flakey connectivity, you don't want a persistent connection if you can use stateless HTTP requests instead.

Upvotes: 2

Related Questions