我正在尝试在特定文件夹中创建一个sqlite数据库但是当我运行以下代码时,它不会创建数据库文件?
码:
/**path to the sqlite database folder that contains all .db files*/
public static final String SQLITE_DATABASE_FOLDER = "c:"+File.separator+"MainWorkspace"+File.separator+"SQLiteDB_Assets"+File.separator+"SQLiteDB";
....
....
....
//in the main method
NodeFactory nodeFactory = new NodeFactory();
nodeFactory.newSQLiteConn(SysConsts.TEST_DATABASE_NAME);
//member method in NodeFactory class
public void newSQLiteConn(String dbName) throws ClassNotFoundException, SQLException {
if (dbName != null) {
if (!dbName.isEmpty()) {
this.dbName = dbName;
Class.forName("org.sqlite.JDBC");
this.dbURL = "jdbc:sqlite:"+SysConsts.SQLITE_DATABASE_FOLDER+File.separator+this.dbName;
} else {
Log.e(TAG, "newSQLiteConn", "dbName is empty");
}
} else {
Log.e(TAG, "newSQLiteConn", "dbName is null");
}
}
请告诉我为什么不创建数据库文件?
答案 0 :(得分:1)
SQLite允许您在实际创建数据库文件之前设置参数(如页面大小)。
文件是在您实际写入文件时创建的(例如,创建一个表格)。