Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can i use postgresql in android phone?

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.

like image 557
bikash shrestha Avatar asked Nov 02 '15 09:11

bikash shrestha


2 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:

mydb=#

PostgreSQL is up and running now.

like image 135
razor8088 Avatar answered Sep 19 '22 12:09

razor8088


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

like image 25
Sebastien Diot Avatar answered Sep 22 '22 12:09

Sebastien Diot