我正在尝试从Kotlin文件查询内容提供者。请参见下面的代码:
var URI = Uri.parse("content://myprovider")
var nameUri = Uri.withAppendedPath(URI, "name")
cursor = contentResolver.query(nameUri, null, null, null, null)
Run Code Online (Sandbox Code Playgroud)
When I run this code, I am getting below error
Caused by: java.lang.IllegalArgumentException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkParameterIsNotNull, parameter projection
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:165)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:418)
at android.content.ContentResolver.query(ContentResolver.java:802)
Run Code Online (Sandbox Code Playgroud)
Now, when I checked the query method signature in ContentResolver class, this is what it is
public final @Nullable Cursor query(@RequiresPermission.Read @NonNull Uri uri,
@Nullable String[] projection, @Nullable String selection,
@Nullable String[] …Run Code Online (Sandbox Code Playgroud) android android-contentresolver android-contentprovider kotlin