我正在尝试打开 sqlite jdbc 连接,但我不断收到异常
java.sql.SQLException: opening db: '\data\data\com.lppapp.ioi.lpp\databases\lppDB.db': Read-only file system
在尝试获取 jdbc 连接之前,我将数据库复制到内部存储中并尝试从那里访问它。我正在使用此代码进行连接:
public Connection connect() {
String url = "jdbc:sqlite:\\data\\data\\com.lppapp.ioi.lpp\\databases\\lppDB.db";
Connection conn = null;
try {
Properties config = new Properties();
config.setProperty("open_mode", "1");
//TODO: can't open db (read-only file system) even though directory has a+rw permissions
conn = DriverManager.getConnection(url, config);
System.out.println("Connection successful.");
} catch (SQLException e) {
System.out.println("Connection failed.");
System.out.println(e.getMessage());
}
return conn;
}
我正在使用 Android 模拟器,并且我已经检查了数据库目录的权限。
我已经尝试了网上找到的所有解决方案,但没有任何帮助。
最佳答案
我决定使用 CommonsWare 提到的 Android 原生 SQLite API。
谢谢!
关于java - Android sqlite jdbc由于只读文件系统而无法连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47815305/