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.
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.
Apparently, now you can, using Termux (a terminal emulator and Linux environment for Android and Chromebook).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With