rgb-tool
rgb-tool copied to clipboard
android.database.CursorIndexOutOfBoundsException
Application version: 11 Android version: Android 6.0 Device: Galaxy Note4 (trlte)
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { dat=content://pl.solidexplorer.files/storage/emulated/0/DCIM/Camera/PermisVertVerso.jpg typ=image/jpeg }} to activity {com.fastebro.androidrgbtool/com.fastebro.androidrgbtool.ui.MainActivity}: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
at android.app.ActivityThread.deliverResults(ActivityThread.java:4921)
at android.app.ActivityThread.handleSendResult(ActivityThread.java:4964)
at android.app.ActivityThread.access$1600(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1848)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7225)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0
at android.database.AbstractCursor.checkPosition(AbstractCursor.java:460)
at android.database.AbstractWindowedCursor.checkPosition(AbstractWindowedCursor.java:136)
at android.database.AbstractWindowedCursor.getString(AbstractWindowedCursor.java:50)
at android.database.CursorWrapper.getString(CursorWrapper.java:137)
at com.fastebro.androidrgbtool.ui.MainActivity.a(Unknown Source)
at com.fastebro.androidrgbtool.ui.MainActivity.onActivityResult(Unknown Source)
at android.app.Activity.dispatchActivityResult(Activity.java:7137)
at android.app.ActivityThread.deliverResults(ActivityThread.java:4917)
... 9 more
Pkg: com.fastebro.androidrgbtool Exception: android.database.CursorIndexOutOfBoundsException: Index 0 requested, with a size of 0 Exception Category: Index error
Root cause: The cursor in Method "com.fastebro.androidrgbtool.ui.MainActivity.getRealPathFromURI" has not check whether the query result is empty or not(i.e.,if (cursor.moveToFirst()))
Description: When querying database, it may failed, better to check whether the return value is null or not; Besides, the cursor is at index -1 by default, call "MoveToFirst()" before data access and also check if it's empty. Note: "null" and "empty" are different.
Possible Fixes: 1: Use if((cursor != null) and (!cursor.MoveToFirst())) to check. 2: Use while(!cursor.MoveToNext()) to iterate when using loop clause.
I'm look forward to your reply.
Yes, if you look at the current code, you can see a check was added to fix potential NPEs, but probably it is not done properly.