androidx.core.content
Classes
ContentResolverCompat |
Helper for accessing features in |
ContextCompat |
Helper for accessing features in |
FileProvider |
FileProvider is a special subclass of |
IntentCompat |
Helper for accessing features in |
MimeTypeFilter |
Provides utility methods for matching MIME type filters used in ContentProvider. |
PermissionChecker |
This class provides permission check APIs that verify both the permission and the associated app op for this permission if such is defined. |
SharedPreferencesCompat |
Top-level functions summary
ContentValues |
contentValuesOf(vararg pairs: Pair<String, Any?>) Returns a new ContentValues with the given key/value pairs as elements. |
Extension functions summary
For android.content.Context | |
T? |
Return the handle to a system-level service by class. |
Unit |
Context.withStyledAttributes(set: AttributeSet? = null, attrs: IntArray, @AttrRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0, block: TypedArray.() -> Unit) Executes block on a TypedArray receiver. |
Unit |
Context.withStyledAttributes(@StyleRes resourceId: Int, attrs: IntArray, block: TypedArray.() -> Unit) Executes block on a TypedArray receiver. |
For android.content.SharedPreferences | |
Unit |
SharedPreferences.edit(: Boolean = false, : Editor.() -> Unit) Allows editing of this preference instance with a call to apply or commit to persist the changes. |
Top-level functions
contentValuesOf
fun contentValuesOf(vararg pairs: Pair<String, Any?>): ContentValues
Returns a new ContentValues with the given key/value pairs as elements.
Exceptions | |
---|---|
IllegalArgumentException |
When a value is not a supported type of ContentValues. |
Extension functions
edit
inline fun SharedPreferences.edit(: Boolean = false, : Editor.() -> Unit): Unit
Allows editing of this preference instance with a call to apply or commit to persist the changes. Default behaviour is apply.
prefs.edit {
putString("key", value)
}
To commit changes:
prefs.edit(commit = true) {
putString("key", value)
}
getSystemService
inline fun <reified T : Any> Context.getSystemService(): T?
Return the handle to a system-level service by class.
See Also
withStyledAttributes
inline fun Context.withStyledAttributes(set: AttributeSet? = null, attrs: IntArray, @AttrRes defStyleAttr: Int = 0, @StyleRes defStyleRes: Int = 0, block: TypedArray.() -> Unit): Unit
Executes block on a TypedArray receiver. The TypedArray holds the attribute
values in set that are listed in attrs. In addition, if the given AttributeSet
specifies a style class (through the style
attribute), that style will be applied
on top of the base attributes it defines.
Parameters | |
---|---|
set |
The base set of attribute values. |
attrs |
The desired attributes to be retrieved. These attribute IDs must be sorted in ascending order. |
defStyleAttr |
An attribute in the current theme that contains a reference to a style resource that supplies defaults values for the TypedArray. Can be 0 to not look for defaults. |
defStyleRes |
A resource identifier of a style resource that supplies default values for the TypedArray, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults. |
withStyledAttributes
inline fun Context.withStyledAttributes(@StyleRes resourceId: Int, attrs: IntArray, block: TypedArray.() -> Unit): Unit
Executes block on a TypedArray receiver. The TypedArray holds the the values defined by the style resource resourceId which are listed in attrs.
Parameters | |
---|---|
attrs |
The desired attributes. These attribute IDs must be sorted in ascending order. |