I need to connect to postgreSQL. When I try to run this code I got exception caused by: NetworkOnMyThreadExcepion. I've made new Thread, but it's still same problem.
...
final ErrorFragment error = new ErrorFragment();
...
new Thread(new Runnable(){
public void run(){
/* Properties prop, String url*/
try {
Connection conn = DriverManager.getConnection(url, prop);
} catch (final SQLException e) {
MainActivity.this.runOnUiThread(new Runnable(){
public void run(){
error.setArguments(exceptionToBundle(e));
error.show(getFragmentManager(), "tagError");
}
});
}
}
}).run();
...
private Bundle exceptionToBundle(Exception e){
...
}