SimpleStorage is written in Kotlin but is compatible with Java. To use it in a Java project, you must interact with Kotlin's object classes and extension functions using specific Java syntax.
Accessing Utility Functions
Utility functions are stored in Kotlin object classes like DocumentFileCompat and MediaStoreCompat.
In Java, you must append .INSTANCE to the class name to access these functions, unless the function is annotated with @JvmStatic.
Accessing Extension Functions
Kotlin extension functions (e.g., those in DocumentFileExtKt or FileExtKt) are available in Java as static methods. Since version 0.4.2, these are typically accessed via classes renamed with the Utils suffix (e.g., DocumentFileUtils).
Version Compatibility Warning
Important: Long-running functions such as copy, move, search, compress, and unzip are only available in Kotlin. If you require these features in a Java project, you must use version 1.5.6 or earlier, as it is the last version providing Java support for these specific operations.
// Accessing a utility function from a Kotlin object
DocumentFile file = DocumentFileCompat.INSTANCE.fromSimplePath(context, "AAAA-BBBB", "Music/My Love.mp3");
// Accessing an extension function (renamed to Utils in Java)
String storageId = DocumentFileUtils.getStorageId(file, context);