Android - Illegalstateexception : Cursor.getstring(idx) Must Not Be Null
I have follow all the stuffs here, but Why does cursor.getString(idx) said it must not be null? I supply all the necessary params.. here's my getfilepath: fun getFilePathFromUri(co
Solution 1:
Per the documentation of cursor.getString():
Returns the value of the requested column as a String.
The result and whether this method throws an exception when the column value is null or the column type is not a string type is implementation-defined.
You're getting an IllegalStateException
. Though broad, this generally means that a method has been invoked at a wrong/illegal time. That is, the the application or environment is not in the proper state for this method. This could mean that the parameter, cursor, or value is null.
Check the return type of the column before calling the method:
if (cursor.getType(idx) == FIELD_TYPE_STRING) {
result = cursor.getString(idx);
}
Post a Comment for "Android - Illegalstateexception : Cursor.getstring(idx) Must Not Be Null"