Skip to content
This repository has been archived by the owner on Jan 7, 2023. It is now read-only.
/ FileF Public archive

Example implementations for the reading folders and files in Android storage

License

Notifications You must be signed in to change notification settings

Foxpace/FileF

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FileF - search for the biggest files in the phone

APILicense

loading

merged_app

With new versions of the Android, it is becomes harder and harder to access storage via some APIs. The FileF collects 4 different approaches to access storage in Android, which work with fine until the Android 10. Android 11 and higher requires MANAGE_APP_ALL_FILES_ACCESS_PERMISSION to access all the files in the background via older APIs. If the app needs this permissions and is released on Google Play, it needs to serve specific purpose like file browser, antivirus, ... - more on that here. Otherwise, you should use scoped storage - more here.

The app takes folders as inputs and number of the number of the biggest files to be found. Also you can choose algorithm, which will search the folders. The app supports parallel search in SD card and external memory of the phone.

Approaches

  • File API - The Android can use java old-fashioned File API, which is compatible with all the Android versions - in my tests the fastest
  • Nio Files API - Compatible with Android Oreo and higher - have its own implementation to walk through the all folders
  • Content resolver - usage of queries to find files in the folder - unfortunately, the conditions for the query are ignored and is the slowest among the APIs
  • Apache Commons IO - wrapper for the Nio Files API, which can be used in lower versions of the Android License

App organization

The main folder of the app is 'utils', where all the methods can be found:

  • sorters
    • BiggestFileGatherer.kt - Keeps sorted array by size. Insertion is being done by InsertionSort. Accepts File, Uri, Path objects.
    • Sorting.kt - InsertionSort and QuickSort implementations
  • types - SavedFile.kt - basic object, which saves path, uri and size of the file
  • walkers
    • Walker.kt - abstract class, which has BiggestFileGatherer and method to customized, so the walkers are in organized manner
    • implementations: WalkerApacheIO.kt / WalkerContentResolver.kt / WalkerFiles.kt / WalkerFilesOreo.kt
  • CustomFileUtils.kt - helper functions to get path to SD, adding to Sets, duplication preventions, ...
  • WalkerFactory.kt - generates the required Walker
  • WalkerIterator.kt - takes list of the folders to be searched in, iterates through them and merges the results of all folders into one
  • WalkerListener.kt - interface, which the UI should have, so it can show the progress

Used libraries

  • Apache Commons IO - Apache Commons IO is a library of utilities to assist with developing IO functionality. License
  • SimpleStorage - 💾 Simplify Android Storage Access Framework for file management across API levels. License
  • Toasty - The usual Toast, but with steroids 💪 License: GPL v3

About

Example implementations for the reading folders and files in Android storage

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages