Google is committed to advancing racial equity for Black communities. See how.

androidx.core.util

Interfaces

Consumer

Compat version of java.util.function.Consumer

Pool

Interface for managing a pool of objects.

Predicate

Compat version of java.util.function.Predicate

Supplier

Compat version of java.util.function.Supplier

Classes

AtomicFile

Static library support version of the framework's android.util.AtomicFile, a helper class for performing atomic operations on a file by writing to a new file and renaming it into the place of the original file after the write has successfully completed.

ObjectsCompat

This class consists of static utility methods for operating on objects.

Pair

Container to ease passing around a tuple of two objects.

PatternsCompat

Commonly used regular expression patterns.

Pools

Helper class for creating pools of objects.

Top-level functions summary

LruCache<K, V>
lruCache(maxSize: Int, crossinline sizeOf: (key: K, value: V) -> Int = { _, _ -> 1 }, crossinline create: (key: K) -> V? = { null as V? }, crossinline onEntryRemoved: (evicted: Boolean, key: K, oldValue: V, newValue: V?) -> Unit = { _, _, _, _ -> })

Creates an LruCache with the given parameters.

infix Range<T>
T.rangeTo(that: T)

Creates a range from this Comparable value to that.

Extension functions summary

For android.util.AtomicFile
ByteArray

Gets the entire content of this file as a byte array.

String
AtomicFile.readText(charset: Charset = Charsets.UTF_8)

Gets the entire content of this file as a String using UTF-8 or specified charset.

Unit

Perform the write operations inside block on this file.

Unit

Sets the content of this file as an array of bytes.

Unit
AtomicFile.writeText(text: String, charset: Charset = Charsets.UTF_8)

Sets the content of this file as text encoded using UTF-8 or specified charset.

For android.util.LongSparseArray
operator Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains value.

Unit
LongSparseArray<T>.forEach(action: (key: Long, value: T) -> Unit)

Performs the given action for each key/value entry.

T
LongSparseArray<T>.getOrDefault(key: Long, defaultValue: T)

Return the value corresponding to key, or defaultValue when not present.

T
LongSparseArray<T>.getOrElse(key: Long, defaultValue: () -> T)

Return the value corresponding to key, or from defaultValue when not present.

Boolean

Return true when the collection contains no elements.

Boolean

Return true when the collection contains elements.

LongIterator

Return an iterator over the collection's keys.

operator LongSparseArray<T>

Creates a new collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

Boolean
LongSparseArray<T>.remove(key: Long, value: T)

Removes the entry for key only if it is mapped to value.

operator Unit
LongSparseArray<T>.set(key: Long, value: T)

Allows the use of the index operator for storing values in the collection.

Iterator<T>

Return an iterator over the collection's values.

For android.util.Pair
operator F
Pair<F, S>.component1()

Returns the first component of the pair.

operator S
Pair<F, S>.component2()

Returns the second component of the pair.

Pair<F, S>

Returns this Android Pair as a Kotlin Pair.

For android.util.Range
infix Range<T>
Range<T>.and(other: Range<T>)

Return the intersection of this range and other.

operator Range<T>
Range<T>.plus(value: T)

Return the smallest range that includes this and value.

operator Range<T>
Range<T>.plus(other: Range<T>)

Return the smallest range that includes this and other.

ClosedRange<T>

Returns this Range as a ClosedRange.

For android.util.Size
operator Int

Returns "width", the first component of this Size.

operator Int

Returns "height", the second component of this Size.

For android.util.SizeF
operator Float

Returns "width", the first component of this SizeF.

operator Float

Returns "height", the second component of this SizeF.

For android.util.SparseArray
operator Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains value.

Unit
SparseArray<T>.forEach(action: (key: Int, value: T) -> Unit)

Performs the given action for each key/value entry.

T
SparseArray<T>.getOrDefault(key: Int, defaultValue: T)

Return the value corresponding to key, or defaultValue when not present.

T
SparseArray<T>.getOrElse(key: Int, defaultValue: () -> T)

Return the value corresponding to key, or from defaultValue when not present.

Boolean

Return true when the collection contains no elements.

Boolean

Return true when the collection contains elements.

IntIterator

Return an iterator over the collection's keys.

operator SparseArray<T>

Creates a new collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

Boolean
SparseArray<T>.remove(key: Int, value: T)

Removes the entry for key only if it is mapped to value.

operator Unit
SparseArray<T>.set(key: Int, value: T)

Allows the use of the index operator for storing values in the collection.

Iterator<T>

Return an iterator over the collection's values.

For android.util.SparseBooleanArray
operator Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains key.

Boolean

Returns true if the collection contains value.

Unit
SparseBooleanArray.forEach(action: (key: Int, value: Boolean) -> Unit)

Performs the given action for each key/value entry.

Boolean

Return the value corresponding to key, or defaultValue when not present.

Boolean
SparseBooleanArray.getOrElse(key: Int, defaultValue: () -> Boolean)

Return the value corresponding to key, or from defaultValue when not present.

Boolean

Return true when the collection contains no elements.

Boolean

Return true when the collection contains elements.

IntIterator

Return an iterator over the collection's keys.

operator SparseBooleanArray

Creates a new collection by adding or replacing entries from other.

Unit

Update this collection by adding or replacing entries from other.

Boolean

Removes the entry for key only if it is mapped to value.

operator Unit

Allows the use of