pFiles guide

The full reference. For an overview, see the README. A small file manager for Android, with a built-in code editor, read-only text viewer and hex editor.

pFiles has zero library dependencies. It uses only the Android framework and the Kotlin standard library: no AndroidX, no support libraries, no image assets. All screens are built in code and all icons are vector drawables, so the release APK is measured in kilobytes.

Features

File browser

Text editor

Read-only text viewer

Used automatically for files over 1 MB, binary files and files you can't write to.

Hex editor

Opening files from other apps

pFiles appears in other apps' Open with and Share lists as pFiles Editor (text-like files) and pFiles Hex (any file). It handles ACTION_VIEW, ACTION_EDIT and ACTION_SEND.

Building

Requirements: JDK 17+ and the Android SDK (platform 35).

./gradlew assembleDebug     # app/build/outputs/apk/debug/
./gradlew assembleRelease   # app/build/outputs/apk/release/
./gradlew testDebugUnitTest # JVM unit tests (JUnit is test-only; the APK has no dependencies)

Or open the project in Android Studio / IntelliJ IDEA and run it.

Release builds use R8 with resource shrinking, and the Kotlin compiler's runtime null-check assertions are turned off to keep the dex small. The release build is signed with the debug key so it installs straight away. Configure your own signingConfig in app/build.gradle.kts before publishing.

Permissions

Android versionWhat pFiles asks for
11+ (API 30+)"All files access" (MANAGE_EXTERNAL_STORAGE), granted from a banner that opens the system settings page
6–10 (API 23–29)READ_EXTERNAL_STORAGE / WRITE_EXTERNAL_STORAGE at runtime
5.x (API 21–22)Granted at install

Publishing to Google Play with MANAGE_EXTERNAL_STORAGE requires a permission declaration for review.

Project layout

app/src/main/java/x/vladgba/files/
├── MainActivity.kt      file browser: list/grid, breadcrumbs, sorting, selection, file operations
├── FileAdapter.kt       list rows and grid tiles, drawn type badges
├── Entry.kt             file snapshot + type → colour mapping
├── FileOps.kt           copy / move / delete / unique names / atomic write (background thread)
├── Storage.kt           storage roots and permission handling
├── FilesProvider.kt     minimal content:// provider for sharing and "open with"
├── Openers.kt           module registry (see below), write-back for files opened from other apps
├── OpenActivity.kt      entry point for VIEW / EDIT / SEND intents from other apps
├── EditorActivity.kt    text editor screen, undo/redo history
├── CodeEditText.kt      EditText with gutter, unprintable markers and kinetic scrolling
├── Highlighter.kt       async line-by-line highlighter for the editor
├── Syntax.kt            languages, line tokenizer, colour palettes
├── ViewerActivity.kt    read-only paged text viewer (ByteSource, LineIndex)
├── HexActivity.kt       hex editor (HexDoc paged document)
├── ZipActivity.kt       archive previewer (ZipTree, virtual folders, APK banner)
├── ZipOps.kt            zip compress / extract / tree inspection
├── TarOps.kt            tar / tgz / gz archive parser and extraction
├── ArchiveOps.kt        unified archive gateway (.zip, .apk, .tar, .tgz, .gz)
├── Fonts.kt             runtime selection of a truly monospace font
└── Ui.kt                small shared UI helpers (dp, insets, dialogs)

Modules

Built-in viewers are modules registered in Openers.all. When you tap a file, the first enabled module whose canOpen() returns true handles it. The menu entry Modules switches each one on or off (Openers.modules is the enabled subset). Anything unclaimed goes to an external app via ACTION_VIEW, and "Open with…" lists every module plus other installed apps.

interface FileOpener {
    val id: String                       // stable id, used in preferences
    val title: Int                       // name shown in "Open with…"
    fun canOpen(f: File): Boolean        // claim the file on a plain tap
    fun open(a: Activity, f: File)
}

Current modules, in claim order:

ModuleClaims on tapNotes
RtfModule.rtfPreview
MarkdownModuleMarkdown filesRendered view
ImageModulejpg, png, gif, webp, bmp, heic, avifPinch zoom, double tap, swipe or menu for the next image in the folder, EXIF in Properties. Decoded downsampled, so big photos are safe
MediaModulecommon audio and videoPlatform VideoView; music continues through the folder, position survives rotation
PdfModule.pdfPlatform PdfRenderer; pages render as they scroll into view, zoom 100 to 400 percent, go to page. Password-protected files are not supported
SqliteModule.db, .sqlite, .sqlite3, .db3 with an SQLite headerRead-only: tables and views with row counts, 500 rows per page, long-press shows the schema
TextModuletext filesEditor; large or read-only files are routed to the viewer
ViewerModulenothing (Open with)Read-only text viewer
HexModulenothing (Open with)Hex editor
ZipModulearchivesZIP family, TAR, GZ, and read-only 7z and RAR4 through ExtraArchives
TableModulenothing (Open with)CSV/TSV with delimiter detection, JSON arrays and JSON lines, up to 16 MB and 50,000 rows
ApkModulenothing (Open with)Version, installed version, SDK levels, signing certificate, components and permissions

To add one, implement FileOpener, add its activity to the manifest and add it to Openers.all.

FTP module

All FTP and SFTP code lives in the ftpmodule APK (x.vladgba.files.ftp): the FTP client (commons-net), the SFTP client (JSch), the embedded FTP server and the SFTP server (Apache MINA SSHD). pFiles binds to it through the hand-written binder IFtpService and only the same signing key may call it. Version 2 added serverStart, serverStop and serverStatus: the module runs the servers as its own foreground service and needs its own access to all files, so pFiles opens the module's screen to ask for it. Edited files opened from a server are uploaded back when you save.

Other features

Licence

MIT. See LICENSE.