Name:
java.lang.IllegalStateException
Reason:
Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
Stack Trace:
0
java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
1
at
android.database.CursorWindow.nativeGetString(Native Method)
2
at
android.database.CursorWindow.getString(CursorWindow.java:438)
3
at
android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
4
at
android.database.CursorWrapper.getString(CursorWrapper.java:114)
5
at
com.travelzoo.android.ui.MapDealsActivity$1.onLoadFinished(MapXXXXActivity.java:****)
6
at
com.travelzoo.android.ui.MapDealsActivity$1.onLoadFinished(MapXXXXActivity.java:1)
7
at
android.support.v4.app.LoaderManagerImpl$LoaderInfo.callOnLoadFinished(LoaderManager.java:427)
8
at
android.support.v4.app.LoaderManagerImpl$LoaderInfo.onLoadComplete(LoaderManager.java:395)
9
at
android.support.v4.content.Loader.deliverResult(Loader.java:104)
10
at
android.support.v4.content.CursorLoader.deliverResult(CursorLoader.java:73)
11
at
android.support.v4.content.CursorLoader.deliverResult(CursorLoader.java:35)
12
at
android.support.v4.content.AsyncTaskLoader.dispatchOnLoadComplete(AsyncTaskLoader.java:223)
13
at
android.support.v4.content.AsyncTaskLoader$LoadTask.onPostExecute(AsyncTaskLoader.java:61)
14
at
android.support.v4.content.ModernAsyncTask.finish(ModernAsyncTask.java:461)
15
at
android.support.v4.content.ModernAsyncTask.access$500(ModernAsyncTask.java:47)
16
at
android.support.v4.content.ModernAsyncTask$InternalHandler.handleMessage(ModernAsyncTask.java:474)
17
at
android.os.Handler.dispatchMessage(Handler.java:99)
18
at
android.os.Looper.loop(Looper.java:137)
19
at
android.app.ActivityThread.main(ActivityThread.java:5328)
20
at
java.lang.reflect.Method.invokeNative(Native Method)
21
at
java.lang.reflect.Method.invoke(Method.java:511)
22
at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
23
at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
24
at
dalvik.system.NativeStart.main(Native Method)
Fix
0. Try to position cursor by moveToFirst before reading data from it.
1. Close the cursor after if ( c.moveToFirst()) {}
2. check for null.e,g; if (c != null && c.moveToFirst()) {}
3. check for count.e,g; (c != null && c.getCount() >0 && c.moveToFirst()){}