0

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.

2
  • Android can connect PostgreSQL using JDBC, please look at: stackoverflow.com/questions/10903481/… Commented Feb 25, 2014 at 21:04
  • 2
    A huge reason you should NEVER have a direct database connection inside your Android application is that your database credentials will not be secure. If you want to make database requests, you should use the approach of a web-server that securely talks to the database and returns the desired result to your application. Commented Feb 25, 2014 at 21:11

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.