Package-level declarations
Cleaner manager.
Cleaner
Cleaner Launcher
There is a situation when it is necessary to synchronize the work of the cleaners. For this purpose, a separate functionality was created that allows you to do this without any difficulty.
This functionality synchronizes the work of existing cleaners. Nothing prevents you from subscribing to a specific cleaner and tracking its work in the launcher.
Analysis
The following code example demonstrates how to use the analysis operation:
// Get the launcher through the cleaner manager
val launcher = cleanerManager.launcher
// List of cleaners for the launcher
val cleanerList: List<Cleaner>
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
launcher.analyze(
cleaners = cleanerList,
isFullRefresh = true
)
}A cleaner is represented by an object that implements the CleanerLauncher interface, a analyze method that takes the following two parameters:
cleaners: List<Cleaner>- list of cleanersisFullRefresh: Boolean-true- when analyzing, the cleaner scans the system again;false- the method returns the cached parsing result (only non-deleted items).
Cleaning
Use the following code example to clear items.
// Get the launcher through the cleaner manager
val launcher = cleanerManager.launcher
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Get a list of items to remove
val trashItemList: List<TrashItem>
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
launcher.clean(
items = trashItemList
)
}A cleaner is represented by an object that implements the Cleaner interface, whose clean method accepts content: List<TrashItem> (list of items to remove)
Getting results
In order to get the state of the cleaner and the results of its work, you need to subscribe to its state as follows:
// Get the launcher through the cleaner manager
val launcher = cleanerManager.launcher
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Subscribe to the states of the launcher
launcher.stateFlow.collect { cleanerState -> // cleanerState: CleanerState
// Do something...
}
}Launcher cleaner inherits Cleaner interface that provides stateFlow: StateFlow (StateFlow) which emits CleanerState objects containing information about the condition of the cleaner. Here are the following possible states of the cleaner:
# - this is the initial state of the cleaner before starting work.
# - this state indicates that the cleaner is in the process of analyzing data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has finished analyzing the data. Includes the following fields:
items: List<TrashItem>- list of found itemserror: Trowable?- an error occurred during the analysis process
# -this state indicates that the cleaner is in the process of deleting data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has completed the data cleaning process. Includes the following fields:
items: List<TrashItem>- list of deleted itemserror: Trowable?- an error occurred during the cleaning process
Links - #, #, #.
Photo Cleaner
Photo Cleaner works in collaboration with Photo SDK to #analysis and #cleaning local media files duplicated in cloud storage.
Before you start working with this module, connect and initialize the photo library in the main module of your project as described in this #getting-started, and also make sure that the Internet is available during the operation.
Analysis
The following code example demonstrates how to use the analysis operation:
// Get the photo cleaner through the cleaner manager
val photoCleaner = cleanerManager.cleaners[CleanerType.PHOTO]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
photoCleaner.analyze(
isFullRefresh = true
)
}The cleaner is represented by an object that implements the interface Cleaner, the method analyze which takes isFullRefresh: Boolean:
true- when analyzing, the cleaner scans the system again;false- the method returns the cached parsing result (only non-deleted items).
Cleaning
Use the following code example to clear items.
// Get the photo cleaner through the cleaner manager
val photoCleaner = cleanerManager.cleaners[CleanerType.PHOTO]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Get a list of items to remove
val trashItemList: List<TrashItem>
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
photoCleaner.clean(
content = trashItemList
)
}A cleaner is represented by an object that implements the Cleaner interface, whose clean method accepts content: List<TrashItem> (list of items to remove)
Getting results
In order to get the state of the cleaner and the results of its work, you need to subscribe to its state as follows:
// Get the photo cleaner through the cleaner manager
val photoCleaner = cleanerManager.cleaners[CleanerType.PHOTO]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Subscribe to the states of the photo cleaner
photoCleaner.stateFlow.collect { cleanerState -> // cleanerState: CleanerState
// Do something...
}
}Photo cleaner inherits Cleaner interface that provides stateFlow: StateFlow (StateFlow) which emits CleanerState objects containing information about the condition of the cleaner. Here are the following possible states of the cleaner:
# - this is the initial state of the cleaner before starting work.
# - this state indicates that the cleaner is in the process of analyzing data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has finished analyzing the data. Includes the following fields:
items: List<PhotoItem>- list of found itemserror: Trowable?- an error occurred during the analysis process
# -this state indicates that the cleaner is in the process of deleting data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has completed the data cleaning process. Includes the following fields:
items: List<PhotoItem>- list of deleted itemserror: Trowable?- an error occurred during the cleaning process
Links - #, #, #.
Downloads Cleaner
The downloads cleaner allows you to #analysis and #cleaning the selected items.
Starting with Android 10, devices use a new type of Scoped Storage. For the downloads cleaner to work within Scoped Storage, you need a $https://developer.android.com/training/data-storage/manage-all-files permission
Analysis
The following code example demonstrates how to use the analysis operation:
// Get the download cleaner through the cleaner manager
val downloadCleaner = cleanerManager.cleaners[CleanerType.DOWNLOAD]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
downloadCleaner.analyze(
isFullRefresh = true
)
}The cleaner is represented by an object that implements the interface Cleaner, the method analyze which takes isFullRefresh: Boolean:
true- when analyzing, the cleaner scans the system again;false- the method returns the cached parsing result (only non-deleted items).
Cleaning
Use the following code example to clear items.
// Get the cleaner downloads through the cleaner manager
val downloadCleaner = cleanerManager.cleaners[CleanerType.DOWNLOAD]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Get a list of items to remove
val trashItemList: List<TrashItem>
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
downloadCleaner.clean(
content = trashItemList
)
}A cleaner is represented by an object that implements the Cleaner interface, whose clean method accepts content: List<TrashItem> (list of items to remove)
Getting results
In order to get the state of the cleaner and the results of its work, you need to subscribe to its state as follows:
// Get the download cleaner through the cleaner manager
val downloadCleaner = cleanerManager.cleaners[CleanerType.DOWNLOAD]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Subscribe to the states of the download cleaner
downloadCleaner.stateFlow.collect { cleanerState -> // cleanerState: CleanerState
// Do something...
}
}Download cleaner inherits Cleaner interface that provides stateFlow: StateFlow (StateFlow) which emits CleanerState objects containing information about the condition of the cleaner. Here are the following possible states of the cleaner:
# - this is the initial state of the cleaner before starting work.
# - this state indicates that the cleaner is in the process of analyzing data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has finished analyzing the data. Includes the following fields:
items: List<DownloadItem>- list of found itemserror: Trowable?- an error occurred during the analysis process
# -this state indicates that the cleaner is in the process of deleting data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has completed the data cleaning process. Includes the following fields:
items: List<DownloadItem>- list of deleted itemserror: Trowable?- an error occurred during the cleaning process
Links - #, #, #.
Thumbnail Cleaner
This type of cleaner is used to clean up the ../.thumblails system folder. This folder is responsible for storing the cache of thumbnails of images on the device. With this type of cleaner, you can #analysis and #cleaning the selected ones.
:::important Starting with Android 10, devices use a new type of Scoped Storage. For the thumbnail cleaner to work within Scoped Storage, you need a $https://developer.android.com/training/data-storage/manage-all-files permission :::
Analysis
The following code example demonstrates how to use the analysis operation:
// Get the thumbnail cleaner through the cleaner manager
val thumbCleaner = cleanerManager.cleaners[CleanerType.THUMBNAI]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
thumbCleaner.analyze(
isFullRefresh = true
)
}The cleaner is represented by an object that implements the interface Cleaner, the method analyze which takes isFullRefresh: Boolean:
true- when analyzing, the cleaner scans the system again;false- the method returns the cached parsing result (only non-deleted items).
Cleaning
Use the following code example to clear items.
// Get the thumbnail cleaner through the cleaner manager
val thumbCleaner = cleanerManager.cleaners[CleanerType.THUMBNAIL]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Get a list of items to remove
val trashItemList: List<TrashItem>
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
thumbCleaner.clean(
content = trashItemList
)
}A cleaner is represented by an object that implements the Cleaner interface, whose clean method accepts content: List<TrashItem> (list of items to remove)
Getting results
In order to get the state of the cleaner and the results of its work, you need to subscribe to its state as follows:
// Get the thumbnail cleaner through the cleaner manager
val thumbCleaner = cleanerManager.cleaners[CleanerType.THUMBNAIL]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Subscribe to the states of the thumbnail cleaner
thumbCleaner.stateFlow.collect { cleanerState -> // cleanerState: CleanerState
// Do something...
}
}Thumbnail cleaner inherits Cleaner interface that provides stateFlow: StateFlow (StateFlow) which emits CleanerState objects containing information about the condition of the cleaner. Here are the following possible states of the cleaner:
# - this is the initial state of the cleaner before starting work.
# - this state indicates that the cleaner is in the process of analyzing data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has finished analyzing the data. Includes the following fields:
items: List<ThumbItem>- list of found itemserror: Trowable?- an error occurred during the analysis process
# -this state indicates that the cleaner is in the process of deleting data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has completed the data cleaning process. Includes the following fields:
items: List<ThumbItem>- list of deleted itemserror: Trowable?- an error occurred during the cleaning process
Links - #, #, #.
Apk Cleaner
The apk cleaner is designed to $analysis and #cleaning files with the '.apk' extension on the device.
:::important Starting with Android 10, devices use a new type of Scoped Storage. For the apk cleaner to work within Scoped Storage, you need a $https://developer.android.com/training/data-storage/manage-all-files permission :::
Analysis
The following code example demonstrates how to use the analysis operation:
// Get the apk cleaner through the cleaner manager
val apkCleaner = cleanerManager.cleaners[CleanerType.APK]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
apkCleaner.analyze(
isFullRefresh = true
)
}The cleaner is represented by an object that implements the interface Cleaner, the method analyze which takes isFullRefresh: Boolean:
true- when analyzing, the cleaner scans the system again;false- the method returns the cached parsing result (only non-deleted items).
Cleaning
Use the following code example to clear items.
// Get the apk cleaner through the cleaner manager
val apkCleaner = cleanerManager.cleaners[CleanerType.APK]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Get a list of items to remove
val trashItemList: List<TrashItem>
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Start the analysis process with the following call
apkCleaner.clean(
content = trashItemList
)
}A cleaner is represented by an object that implements the Cleaner interface, whose clean method accepts content: List<TrashItem> (list of items to remove)
Getting results
In order to get the state of the cleaner and the results of its work, you need to subscribe to its state as follows:
// Get the apk cleaner through the cleaner manager
val apkCleaner = cleanerManager.cleaners[CleanerType.APK]
// Get coroutine scope to call cleaner library functions
val cleanerScope = cleanerManager.scope
// Run all operations related to libraries only in the cleaner library
cleanerScope.launch {
// Subscribe to the states of the apk cleaner
apkCleaner.stateFlow.collect { cleanerState -> // cleanerState: CleanerState
// Do something...
}
}Apk cleaner inherits Cleaner interface that provides stateFlow: StateFlow (StateFlow) which emits CleanerState objects containing information about the condition of the cleaner. Here are the following possible states of the cleaner:
# - this is the initial state of the cleaner before starting work.
# - this state indicates that the cleaner is in the process of analyzing data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has finished analyzing the data. Includes the following fields:
items: List<ApkItem>- list of found itemserror: Trowable?- an error occurred during the analysis process
# -this state indicates that the cleaner is in the process of deleting data. Includes the following fields:
itemCount: Int- number of items foundsize: Long- size of found elements in bits
# - this state indicates that the cleaner has completed the data cleaning process. Includes the following fields:
items: List<ApkItem>- list of deleted itemserror: Trowable?- an error occurred during the cleaning process
Links - #, #, #.
Types
The interface describing the launcher of cleaners. Allows you to start and synchronize the work of cleaners.