sinhsac.github.io / android-cleaner

Android Folder Cleaner

Lightweight, rootless Kotlin utility using Android's Storage Access Framework (SAF) to clean unwanted media inside restricted Android/data folders (such as Kabe View / KBVISION) and safely move camera media to an external SD card with MD5 verification.

Kotlin 1.9.23 Android API 24+ Zero Storage Permissions MD5-Verified SD Move MIT License

Key Features

  • One-Time SAF Grant for Android/data: Opens the system picker directly inside your target folder via EXTRA_INITIAL_URI and persists access across restarts — no root and zero legacy storage permissions in AndroidManifest.xml.
  • Configurable Extensions & BFS Subfolder Scan: Defaults to mp4,jpg and accepts any comma-separated extension list (e.g., mp4,jpg,jpeg,mkv). Subfolder traversal runs iteratively via BFS in CleanerEngine to prevent stack overflows.
  • Live Thumbnail Dry-Run Preview: Automatically scans and previews matched images/videos in a responsive grid with total count and reclaimable size before touching a single file. Tap any thumbnail to inspect it externally.
  • Safe Move to External SD Card (MoveActivity / MoveEngine):
    • Streams files in 64 KB chunks so multi-GB videos never trigger OOM errors.
    • Computes and compares MD5 hashes of source and destination before deleting the original, protecting against faulty SD cards or silent corruption.
    • Skips already-present files with non-zero size, cleans up partial destination files on cancellation, and opens the picker directly at the removable SD card root via StorageManager (bypassing Samsung One UI's hidden drawer).

Accessing Kabe View / KBVISION (Android/data) Without Root

Kabe View (KBVISION VIEW Plus) stores downloaded recordings and snapshots at:

/storage/emulated/0/Android/data/com.mm.android.direct.KBVISIONVIEWPlus/files/Download
1

Open Settings → Choose Folder (SAF)

The app launches Android's document tree picker pre-positioned inside your target path via CleanerEngine.initialPickerUri().

2

Tap "Use This Folder"

Even though Android 11 hides Android/data when browsing manually, jumping straight in via EXTRA_INITIAL_URI allows granting access cleanly.

3

Preview & Clean Anytime

The grant is persisted via takePersistableUriPermission() and reused automatically on every launch.

Why MANAGE_EXTERNAL_STORAGE Fails on Android 11+

Benchmarked directly on a Samsung SM-A507FN (Android 11):

ApproachMeasured Result
targetSdk 28 + requestLegacyExternalStorageFile.listFiles() returns null
MANAGE_EXTERNAL_STORAGE ("All files access")Still returns null even with appop enabled
SAF Tree Grant (DocumentsContract)Full read, preview & delete access without root

Root cause: App processes belong to group 9997 (everybody) rather than 1015 (sdcard_rw), while Android/data has permissions drwxrwx--x root:sdcard_rw. Normal filesystem calls can check exists() via execute bits, but cannot list or unlink files. SAF delegates operations safely through Android's document provider.

Installing on Your Android Phone

Option A: Direct APK or QR Code from GitHub Releases (Recommended)

Every version tag (e.g. v1.0.5) triggers .github/workflows/ok.yml, which compiles the APK, generates a qr.png pointing directly to the APK URL, and publishes both on the Releases page. Scan the QR code with your phone camera to download and sideload immediately.

Option B: Install via ADB

# Linux / macOS
adb install -r app/build/outputs/apk/debug/app-debug.apk

# Windows
D:\android-sdk\platform-tools\adb.exe install -r app\build\outputs\apk\debug\app-debug.apk

Building From Source

Requires JDK 17 and Android SDK (compileSdk 35, minSdk 24, targetSdk 30). Gradle 8.5 is bundled via the wrapper.

git clone https://github.com/sinhsac/android-cleaner.git
cd android-cleaner

# Point to your Android SDK in local.properties (or set ANDROID_HOME)
echo "sdk.dir=/path/to/android-sdk" > local.properties

# Build debug APK
./gradlew :app:assembleDebug
# Output: app/build/outputs/apk/debug/app-debug.apk

Privacy & Safety Notes

Permanent Deletion

Files removed with Clean Now are deleted permanently and do not go to a recycle bin. Always review the thumbnail grid and matched file count before confirming.

  • Zero Manifest Storage Permissions: The app requests neither MANAGE_EXTERNAL_STORAGE nor READ/WRITE_EXTERNAL_STORAGE; access is strictly scoped to user-selected SAF directories.
  • Move to SD Card Scope: MoveEngine.listSourceFiles() scans the selected source directory non-recursively, tailored for flat camera directories like DCIM/Camera.
  • Android 13/14+ Note: Some newer Android builds / OEM Files apps further restrict ACTION_OPEN_DOCUMENT_TREE inside Android/data; full behavior is verified on Android 11 (Samsung SM-A507FN).