Skip to main content

Cleaner SDK

SDK for finding and cleaning up duplicate and unneeded content on the device.

Applies to Cleaner SDK 5.5.2+

Installation

Declare Cloudike's private Maven repository in your project's settings.gradle.kts (artifactory_username/artifactory_password are credentials provided by Cloudike, set in your own gradle.properties):

dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven {
url = uri("https://rt.cloudike.com/artifactory/libs-release-local")
credentials {
username = settings.extra.properties["artifactory_username"].toString()
password = settings.extra.properties["artifactory_password"].toString()
}
}
}
}

Add cleaner and its required core, photos dependencies to your app module's build.gradle.kts and sync the project:

dependencies {
implementation("com.cloudike.sdk:cleaner:<version>")
implementation("com.cloudike.sdk:core:<version>")
implementation("com.cloudike.sdk:photos:<version>")
}

The DOWNLOAD/THUMBNAIL/APK cleaners need the MANAGE_EXTERNAL_STORAGE permission on Android 10+; the PHOTO cleaner additionally needs Photos SDK initialized in your app.

Initialization

import com.cloudike.sdk.cleaner.CleanerManager
import com.cloudike.sdk.core.CoreManager
import kotlinx.coroutines.runBlocking

val coreContext = CoreManager.build(applicationContext)

runBlocking {
coreContext.sessionManager.start(
reset = false,
baseUrl = "https://your-backend.example.com/", // your Cloudike backend endpoint
accessToken = accessToken, // from your sign-in flow
userId = userId, // from your sign-in flow
userAgent = "YourApp/1.0",
)
}

val cleanerManager = CleanerManager.build(coreContext)

Builds the shared CoreContext, starts the user session on it, then builds CleanerManager on the same CoreContext. baseUrl/accessToken/userId/userAgent come from your own sign-in flow — the values shown are placeholders.

First API Call

import com.cloudike.sdk.cleaner.data.CleanerState
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.runBlocking

val result = runBlocking {
cleanerManager.launcher.analyze(
cleaners = cleanerManager.cleaners.values.toList(),
isFullRefresh = true,
)
cleanerManager.launcher.stateFlow.first { it is CleanerState.Analyzed<*> }
}
println("Cleaner analysis result: $result")

Scans the device with every registered cleaner, then waits for the launcher to report the outcome. stateFlow moves from Analyzing to Analyzed with the list of junk items found (possibly empty) — confirming Cleaner SDK can access device storage.