Skip to content

Environment.isExternalStorageWritable not usable #53

@jasonsparc

Description

@jasonsparc

The extension functions for android.os.Environment that is currently provided by KEnvironment.kt cannot be used without first creating an instance of Environment which isn't desirable because android.os.Environment is just meant as a utility class filled with static methods.

To access the provided extension functions I have to write this:

if (Environment().isExternalStorageWritable()) {
  …
}

That is, notice Environment() and not Environment which means I have to create an instance of Environment first before using it.

It is currently not possible in Kotlin to provide static extension functions to existing java classes. See, https://discuss.kotlinlang.org/t/static-extension-methods-for-java-classes/2190

Therefore the extension functions provided by KEnvironment.kt is not usable or practical. I would say either removing it or changing them into top-level functions instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions