Home » Android » can i use postgresql in android phone?

can i use postgresql in android phone?

Posted by: admin June 15, 2020 Leave a comment


I am trying to develop Android application and I want to use database in my application. I know that I can use sqllite in Android, but is it possible to use Postgres instead of sqllite?

I am talking about installing db in phone and not using remote DB server.

Is it possible?

Any answers are appreciated.

How to&Answers:

PostgreSQL is now available for Termux on Andriod

Install Termux from the Play Store and run it.

To install PostgreSQL:

$ pkg install postgresql

To start it first create your folder you want to store the data in and then init te folder:

$ mkdir -p $PREFIX/var/lib/postgresql
$ initdb $PREFIX/var/lib/postgresql

To start the server:

$ pg_ctl -D $PREFIX/var/lib/postgresql start

To stop the server:

$ pg_ctl -D $PREFIX/var/lib/postgresql stop

Create a user to allow you to connect form an App:

$ createuser --superuser --pwprompt yourUserName

Create your database:

$ createdb mydb

Open your database

$ psql mydb

You will now see the promt:


PostgreSQL is up and running now.


Apparently, now you can, using Termux (a terminal emulator and Linux environment for Android and Chromebook).


There is no PostgreSQL port for Android.

PostgreSQL cannot be compiled for Android. And it really would make very little sense: PostgreSQL is particularly suited to large databases and multi-user access. Also, it is unlikely that you need PostGIS’s functionality on an Android device. There are multiple database / spatial data apps out there; or develop your own from available toolkits.