我正在研究一個應用程序,其中info
存儲在database
中。我得到new info
以及my service
,但在提交到我的數據庫之前,我想要check if the new info I have already exists in the database or not.
爲此,我正在查詢數據庫中的特定信息從我的服務,我得到android.database.CursorWindowAllocationException
..我GOOGLE了它,並找到this answer。據此,我得到這個錯誤,因爲我從我的服務查詢數據庫。Android - 從服務中查詢數據庫
任何解決方法?
代碼來查詢數據庫
public String getLogData() {
String[] coloumns = { KEY_NETWORK_INFO };
Cursor c = ourDatabase.query(LOG_TABLE_NAME, coloumns, null, null,
null, null, null);
String result = "";
int iNetworkInfo = c.getColumnIndex(KEY_NETWORK_INFO);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
result = result + c.getString(iNetworkInfo) + ", ";
}
return result;
}
logcat的:
01-21 13:43:00.633: E/AndroidRuntime(14871): android.database.CursorWindowAllocationException: Cursor window allocation of 2048 kb failed. # Open Cursors=762 (# cursors opened by this proc=762)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.CursorWindow.<init>(CursorWindow.java:108)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:198)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:133)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:197)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:237)
01-21 13:43:00.633: E/AndroidRuntime(14871): at com.iqra.adeel.newfyp.part1.AreaDatabase.getLogData(AreaDatabase.java:153)
01-21 13:43:00.633: E/AndroidRuntime(14871): at com.iqra.adeel.newfyp.part1.MyService$MyPhoneStateListener.onSignalStrengthsChanged(MyService.java:102)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.telephony.PhoneStateListener$1.handleMessage(PhoneStateListener.java:301)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.os.Handler.dispatchMessage(Handler.java:102)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.os.Looper.loop(Looper.java:135)
01-21 13:43:00.633: E/AndroidRuntime(14871): at android.app.ActivityThread.main(ActivityThread.java:5223)
01-21 13:43:00.633: E/AndroidRuntime(14871): at java.lang.reflect.Method.invoke(Native Method)
01-21 13:43:00.633: E/AndroidRuntime(14871): at java.lang.reflect.Method.invoke(Method.java:372)
01-21 13:43:00.633: E/AndroidRuntime(14871): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
01-21 13:43:00.633: E/AndroidRuntime(14871): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
可能重複[2048 KB的SQLite的Android的數據庫遊標窗口分配失敗(HTTP關閉://stackoverflow.com/questions/11340257/sqlite-android-database-cursor-window-allocation-of-2048-kb-failed) – 2015-01-21 09:14:43