当尝试通过从 Internet 页面获取的查询来更新我的数据库时,我得到了一个异常。这是代码:
url = new URL(Database.Munawwat_UpdateDB_URL);
URLConnection connection = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line = null;
File dbfile = new File(Database.Munawwat_Database_PATH);
if (!dbfile.exists()) {
Toast.makeText(Munawwat_List.this, "error in db location", Toast.LENGTH_SHORT).show();
return;
}
SQLiteDatabase db = SQLiteDatabase.openOrCreateDatabase(dbfile, null);
String query = "";
while ((line = reader.readLine()) != null)
if (!line.contains("WHERE"))
query += line + "\n";
else {
query += line.trim();
Cursor c = db.rawQuery(query, null);
c.moveToFirst();
c.close();
query = "";
}
db.close();
reader.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
日志猫:
14:52:46.136: E/SQLiteQuery(17802): exception: not an error; query: UPDATE Adab SET Body="AAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBCBCBCB" WHERE _id=4 10-14
14:52:47.484: W/System.err(17802): android.database.sqlite.SQLiteException: not an error 10-14
14:52:47.496: W/System.err(17802): at android.database.sqlite.SQLiteQuery.nativeFillWindow(Native Method) 10-14
14:52:47.503: W/System.err(17802): at android.database.sqlite.SQLiteQuery.fillWindow(SQLiteQuery.java:86) 10-14
14:52:47.511: W/System.err(17802): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:164) 10-14
14:52:47.523: W/System.err(17802): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:156) 10-14
14:52:47.527: W/System.err(17802): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:161) 10-14
14:52:47.527: W/System.err(17802): at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:201) 10-14
14:52:47.531: W/System.err(17802): at omar.Munawwat_List$2.onClick(Munawwat_List.java:141) 10-14
14:52:47.531: W/System.err(17802): at android.view.View.performClick(View.java:3511) 10-14
14:52:47.535: W/System.err(17802): at android.view.View$PerformClick.run(View.java:14105) 10-14
14:52:47.535: W/System.err(17802): at android.os.Handler.handleCallback(Handler.java:605) 10-14
14:52:47.535: W/System.err(17802): at android.os.Handler.dispatchMessage(Handler.java:92) 10-14
14:52:47.539: W/System.err(17802): at android.os.Looper.loop(Looper.java:137) 10-14
14:52:47.539: W/System.err(17802): at android.app.ActivityThread.main(ActivityThread.java:4575) 10-14
14:52:47.539: W/System.err(17802): at java.lang.reflect.Method.invokeNative(Native Method) 10-14
14:52:47.539: W/System.err(17802): at java.lang.reflect.Method.invoke(Method.java:511) 10-14
14:52:47.542: W/System.err(17802): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) 10-14
14:52:47.542: W/System.err(17802): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 10-14
14:52:47.546: W/System.err(17802): at dalvik.system.NativeStart.main(Native Method)
所以数据库没有得到更新..这是为什么?