It does not connect to the database via jdbc on android below 5.0. On 5, 6, everything works. DB mysql. Here is the code:
try { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); Class.forName("com.mysql.jdbc.Driver").newInstance(); con = DriverManager.getConnection("jdbc:mysql://xxxxxxxx:3306/xxxxxxxx", getString(R.string.login), getString(R.string.pasword)); Statement st = con.createStatement(); ResultSet rs = st.executeQuery("SELECT COUNT(1) FROM smm"); while (rs.next()) { l = new Integer(rs.getInt(1)); } Log.i(TAG,"dbtest-1" +String.valueOf(l)); } catch (Exception e) { e.printStackTrace(); } Many have tried, help, please.
ThreadPolicy, but make an appeal to the database in a separate thread - ermak0ff