Finally, I was able to connect to sdcard, but now I want to connect to a DB in a shared folder on the network. I'm not getting. I have tried several ways and below follows my code case. Every help is welcome.
public class ConnectionClass {
public static Connection conn = null;
public Connection CONN(){
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
String DRIVER = "net.ucanaccess.jdbc.UcanaccessDriver";
String DbDsn = "jdbc:ucanaccess://";
String DbServer = "//192.168.15.4";
String DbPath = "/Banco";
String DbName = "/DBase.accdb";
String ConnUrl= DbDsn + DbServer + DbPath + DbName;
try{
String caminho_2 = DbServer+DbPath+DbName;
System.out.println("Caminho - " + caminho_2);
File teste = new File(caminho_2);
if(teste.exists()) {
System.out.println("Arquivo OK");
}else{
System.out.println("Não OK");
}
try {
System.out.println("Verificação Driver");
Class.forName(DRIVER);
}
catch(ClassNotFoundException cnfex) {
System.out.println("Problem in loading or "
+ "registering MS Access JDBC driver");
cnfex.printStackTrace();
}
System.out.println("Classificando Driver");
System.out.println("String de conexão - " + ConnUrl);
conn = DriverManager.getConnection(ConnUrl);
System.out.println("Conexão Estabelecida");
}catch (SQLException cnfe){
System.out.println(cnfe);
System.out.println("Erro - 1");
}catch (Exception se){
System.out.println(se);
System.out.println("Erro - 2");
}
return conn;
}
}