Answer the question
In order to leave comments, you need to log in
Android Studio connect to PostgreSQL?
Good afternoon folks.
I'm trying to connect to postgresql and I seem to be doing everything according to the article (2020), but I constantly catch errors. and somewhat different for different versions of the driver. with implementation 'org.postgresql:postgresql:42.2.5' connection error (moreover, it crashes somewhere in the driver):
private PostgreData() {
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException e) {
Log.println(Log.ERROR, "SQL", "TestApp");
Log.getStackTraceString(e);
AlertDialog dialog = DialogWnd.getDialog(mainActivity, e.getMessage(), DialogWnd.DLG_ERROR);
assert dialog != null;
dialog.show();
return;
}
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
try {
connection = DriverManager.getConnection(URL); //DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
status = true;
} catch (SQLException e) {
status = false;
Log.println(Log.ERROR, "SQL", "TestApp");
Log.getStackTraceString(e);
AlertDialog dialog = DialogWnd.getDialog(mainActivity, e.getMessage(), DialogWnd.DLG_ERROR);
assert dialog != null;
dialog.show();
}
}
Answer the question
In order to leave comments, you need to log in
Perhaps this question can be closed:
Generally speaking most Android/iPhone apps connect to Postgres through a
"middle tier" API written in Ruby, Python, Java, Node.JS or similar. In
some cases you might sync Postgres to a local SQLite DB on the Android
device more directly, but that would be a pretty specialized and uncommon
implementation strategy.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question