在sqlite数据库中,我借助此代码从资产文件夹中的脚本获取数据库查询.
manager = context.getResources().getAssets();
input = manager.open("createDb.xml");
xpp.setInput(input,null);
int type = xpp.getEventType();
while(type != XmlPullParser.END_DOCUMENT) {
if(type == XmlPullParser.START_DOCUMENT) {
Log.d(Tag,"In start document");
}
else if(type == XmlPullParser.START_TAG) {
Log.d(Tag,"In start tag = "+xpp.getName());
}
else if(type == XmlPullParser.END_TAG) {
Log.d(Tag,"In end tag = "+xpp.getName());
}
else if(type == XmlPullParser.TEXT) {
Log.d(Tag,"Have text = "+xpp.getText());
String strquery = xpp.getText();
db.execsql(strquery);
}
type = xpp.next();
}
}
catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
它的工作正常.
但我在sqlCipher数据库中运行相同的代码,它总是给出这个错误和应用程序崩溃.
即使我已经添加了所有必要的库.
Failure 0 (not an error) on 0x1a1ab0 when executing '
FATAL EXCEPTION: main
net.sqlcipher.database.sqliteException: not an error:
at net.sqlcipher.database.sqliteDatabase.native_execsql(Native Method)
at net.sqlcipher.database.sqliteDatabase.execsql(sqliteDatabase.java:1834)
at com.acs.android.fwk.database.ScriptExecutor.executeScripts(ScriptExecutor.java:86)
at com.acs.android.fwk.database.DatabaseHelper.onCreate(DatabaseHelper.java:55)
at net.sqlcipher.database.sqliteOpenHelper.getWritableDatabase(sqliteOpenHelper.java:121)
at com.acs.android.fwk.database.DatabaseAdapter.open(DatabaseAdapter.java:79)
at com.acs.android.fwk.database.DatabaseAdapter.
请帮忙.
Thansk
最佳答案
原文链接:https://www.f2er.com/android/430826.html