마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

서비스에서 DB값 불러오는 방법좀요..

0 추천

01-14 09:35:42.156 25029-25029/com.example.myapplication E/CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 1 columns.
01-14 09:35:42.166 25029-25029/com.example.myapplication D/AndroidRuntime: Shutting down VM
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime: Process: com.example.myapplication, PID: 25029
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime: java.lang.RuntimeException: Unable to start receiver com.example.myapplication.SMSReceiver: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleReceiver(ActivityThread.java:3001)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.access$1800(ActivityThread.java:178)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1526)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:145)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5944)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:  Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.database.CursorWindow.nativeGetString(Native Method)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.database.CursorWindow.getString(CursorWindow.java:451)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at com.example.myapplication.SMSReceiver.onReceive(SMSReceiver.java:68)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.handleReceiver(ActivityThread.java:2994)
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.access$1800(ActivityThread.java:178) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1526) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:145) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5944) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
01-14 09:35:42.166 25029-25029/com.example.myapplication E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
01-14 09:35:44.576 25029-25029/com.example.myapplication I/Process: Sending signal. PID: 25029 SIG: 9

제가

public class OneView extends Service

돌리는게 있는데요 여기서 DB값을 불러올려고 하는데 저런 로그가 뜨네요<!--EndFragment-->

tv.setText("값"+getString(cursor.getColumnIndex("PHONE")));

이렇게 불러오는데 저런 로그가 나오는데 무슨 이유일까요<!--EndFragment-->

지미니v (1,080 포인트) 님이 2016년 1월 14일 질문

1개의 답변

0 추천
java.lang.RuntimeException: Unable to start receiver com.example.myapplication.SMSReceiver: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:3001)
    at android.app.ActivityThread.access$1800(ActivityThread.java:178)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1526)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:5944)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
 Caused by: java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow.  Make sure the Cursor is initialized correctly before accessing data from it.
    at android.database.CursorWindow.nativeGetString(Native Method)
    at android.database.CursorWindow.getString(CursorWindow.java:451)
    at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:51)
    at com.example.myapplication.SMSReceiver.onReceive(SMSReceiver.java:68)
    at android.app.ActivityThread.handleReceiver(ActivityThread.java:2994)
    at android.app.ActivityThread.access$1800(ActivityThread.java:178) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1526) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:145) 
    at android.app.ActivityThread.main(ActivityThread.java:5944) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 

 

로그를 편집하지 않고 그대로 올리면 답변 달아주려고 들어왔다가 그냥 나가는 사람이 많습니다...

쎄미 (162,410 포인트) 님이 2016년 1월 15일 답변
...