A lightweight, rootless Android utility built in Kotlin to clean unwanted media and junk files (such as *.mp4 and *.jpg left behind by Kabe View / KBVISION VIEW Plus inside Android/data) and safely move camera media to an external SD card.
Grant folder access once via Android's native Storage Access Framework (SAF) picker. The app persists that permission across restarts, previews matching files in a thumbnail grid, and deletes them on demand — without requiring root or broad MANAGE_EXTERNAL_STORAGE permissions.
- One-Time SAF Folder Access (Works with
Android/data): Opens the system document tree picker directly inside your target folder viaEXTRA_INITIAL_URI— includingAndroid/data/...paths that Android 11+ restricts from direct filesystem access. Grant once and reuse permanently. - Configurable File Extensions: Defaults to
mp4,jpgand supports any comma-separated list of extensions (e.g.,mp4,jpg,jpeg,mkv, with or without leading dots). - Recursive Subfolder Scanning: Toggle subfolder traversal on or off (implemented iteratively via BFS in
CleanerEngineto avoid stack overflows on deep trees). - Live Thumbnail Preview (Safe Dry-Run): Opening the app automatically scans the configured folder and renders a responsive thumbnail grid showing the matched file count and total size without deleting anything. Tap any item to inspect it in an external image/video viewer.
- One-Tap Clean with Confirmation: Deletes all matched files after an explicit confirmation dialog and reports the deleted count and reclaimed storage space.
- Safe Move to External SD Card (
MoveActivity/MoveEngine):- Moves files (e.g.,
/storage/emulated/0/DCIM/Camera) from internal storage to a removable SD card via SAF. - Streams files in 64 KB chunks so multi-GB videos never cause out-of-memory (OOM) errors.
- Computes and compares MD5 hashes of the source stream and the written destination file before deleting the original — protecting against silent corruption or faulty SD cards.
- Automatically skips files already present at the destination with the same name and non-zero size, and cleans up partial destination files if a transfer fails or is cancelled mid-way.
- Detects removable SD card volumes via
StorageManagerto open the picker directly at the SD card root (working around Samsung One UI hiding SD cards behind a drawer menu).
- Moves files (e.g.,
On a real device, Kabe View (KBVISION VIEW Plus) stores downloaded recordings and snapshots at:
/storage/emulated/0/Android/data/com.mm.android.direct.KBVISIONVIEWPlus/files/Download
(Note: the subdirectory is Download, singular, verified via adb on Samsung SM-A507FN / Android 11.)
On Android 11+, the only rootless way to access another app's Android/data directory is a SAF tree grant:
- Open Settings in the app and tap Choose folder (SAF) ("Chọn thư mục (SAF)"). The app launches the system folder picker directly inside the configured directory using
EXTRA_INITIAL_URI(CleanerEngine.initialPickerUri()). - Tap Use this folder ("Sử dụng thư mục này").
Step 1 is the key: Android 11's system file picker hides Android/data when you browse downward folder by folder, but when opened directly inside the target path, the Use this folder button still grants access normally. Because SAF tree grants are prefix-based, a grant on an ancestor directory also covers its subdirectories — the exact same technique used by ES File Explorer (which holds a grant on primary:Android/data).
Once granted, the app persists the URI permission (takePersistableUriPermission). At runtime, CleanerEngine.clean() automatically selects SAF (DocumentsContract + direct ContentResolver.query) whenever a persisted grant covers the path, and falls back to java.io.File for standard shared directories (DCIM, Download, etc.) while normalizing common path aliases (/sdcard, /mnt/sdcard, /mnt/0, /storage/self/primary, /mnt/user/0/primary).
Measured directly on a Samsung SM-A507FN running Android 11:
| Approach | Result |
|---|---|
targetSdk 28 + requestLegacyExternalStorage |
File.listFiles() returns null |
MANAGE_EXTERNAL_STORAGE ("All files access") |
Still returns null, even with the appop enabled at UID level |
Root cause: App processes only belong to group 9997 (everybody) and do not belong to 1015 (sdcard_rw), whereas Android/data has permissions drwxrwx--x root:sdcard_rw. Apps fall into the other permission bits (--x), meaning they can traverse into a directory if they know the exact path (exists() and isDirectory() return true), but they cannot list its contents or delete files. This is not an SELinux block (logcat records zero AVC denials).
Switching target folders: Open Settings and tap Choose folder (SAF) to select and persist access to a new folder.
- JDK 17
- Android SDK (
compileSdk 35,minSdk 24,targetSdk 30) - Gradle 8.5 (included via Gradle wrapper — no separate installation needed)
Create a local.properties file in the repository root pointing to your Android SDK (or set the ANDROID_HOME environment variable):
sdk.dir=D:\\android-sdkBuild the debug APK:
# Linux / macOS
./gradlew :app:assembleDebug
# Windows
gradlew.bat :app:assembleDebugThe compiled APK is output to:
app/build/outputs/apk/debug/app-debug.apk
This repository includes .github/workflows/ok.yml (Build & Release APK):
- On every push to
mainormaster(or manualworkflow_dispatch): builds the debug APK and uploads it as a GitHub Actions Artifact (Actionstab → select a run →Artifacts→FolderCleaner-apk). - On every
v*tag push (e.g.,v1.0.5): builds the APK, generates a QR code (qr.png) pointing directly to the APK download URL, and publishes a GitHub Release with both the APK and QR code attached. Open the release page on your phone — or scan the QR code with your phone camera — to download and install immediately.
To cut a new release:
git tag v1.0.5
git push origin main --tagsWait for the workflow in the Actions tab to complete, then grab the APK or scan the QR code from the Releases page. The APK is signed with the default Android debug keystore (ready for direct device installation and testing without managing a separate release keystore).
# Linux / macOS (with adb in PATH)
adb install -r app/build/outputs/apk/debug/app-debug.apk
# Windows (explicit platform-tools path)
D:\android-sdk\platform-tools\adb.exe install -r app\build\outputs\apk\debug\app-debug.apkCopy app-debug.apk (or the downloaded release APK) to your phone and open it to install (enable Install from unknown sources when prompted).
- Zero storage permissions in
AndroidManifest.xml: The app does not requestMANAGE_EXTERNAL_STORAGE,READ_EXTERNAL_STORAGE, orWRITE_EXTERNAL_STORAGE. All UI file operations run exclusively through user-granted SAF (content://) URIs scoped to the exact folders you choose — safer for privacy, andMANAGE_EXTERNAL_STORAGEdoes not grant access toAndroid/dataon Android 11+ anyway. - Re-granting revoked access: If Android revokes persisted folder permissions (or the app prompts that folder access is missing), open Settings and tap Choose folder (SAF) to grant permission again.
- Permanent deletion: Deleted files are removed permanently and do not go to a trash/recycle bin. Always review the thumbnail grid preview and summary count before confirming Clean Now.
- Move to SD Card scope:
MoveEngine.listSourceFiles()lists files directly inside the selected source folder (non-recursive), tailored for flat directories likeDCIM/Camera. - Android 11+ SAF behavior: Some newer Android versions (Android 13/14+) further restrict
ACTION_OPEN_DOCUMENT_TREEonAndroid/datadepending on OEM/Files app updates; behavior verified on Android 11 (Samsung SM-A507FN).
This project is licensed under the MIT License — see the LICENSE file for details.