FileStorageManager

FileStorage manager API - general framework for filesystem usage, it should provide any filesystem related operations in app. File system commits done by FileStorage manager are automatically respect for Scoped Storage conditions since Android Q version.

Properties

Link copied to clipboard
val APP_EXTERNAL: Int = 1
Link copied to clipboard
val BACKUP: Int = 5
Link copied to clipboard
val DOWNLOADS: Int = 4
Link copied to clipboard
val EXTERNAL: Int = 0
Types of storage
Link copied to clipboard
val INTERNAL: Int = 2
Link copied to clipboard
val LOGGING: Int = 7
Link copied to clipboard
val MEDIA: Int = 0
Groups of file contents according the app use cases (could be extended in case of new logical types file system usages created)
Link copied to clipboard
Link copied to clipboard
val QD_ICON: Int = 6
Link copied to clipboard
val RECORDINGS: Int = 1
Link copied to clipboard
val RINGTONES: Int = 2

Functions

Link copied to clipboard
open fun createCacheFile(@NonNull cachePath: Array<String>): File
Create empty cache file.
Link copied to clipboard
open fun createPrivateFile(fileName: String, contentType: Int): File
Create empty private file.
Link copied to clipboard
open fun createUri(@Nullable file: File): Uri
Create a new empty file and build uri for it
Link copied to clipboard
open fun delete(@Nullable file: File): Boolean
Delete file of directory according to :
open fun delete(fileName: String, contentType: Int, storageType: Int): Boolean
Delete file according to :
Link copied to clipboard
Used from native code Delete directory with specified filepath.
Link copied to clipboard
open fun deleteFileNative(@NonNull filePath: String): Boolean
Used from native code Delete file with specified filepath.
Link copied to clipboard
Delete media store file according to :
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getCacheFile(@NonNull cachePath: Array<String>): File
Get a cache file with the supplied path segments.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getFile(@NonNull fileName: String, contentType: Int, storageType: Int): File
Retrieve existed file from file storage according to :
Link copied to clipboard
open fun getFileSize(@NonNull uri: Uri): Long
Link copied to clipboard
open fun getFileSizeNative(@NonNull filePath: String): Int
Used from native code Getting file size in bytes.
Link copied to clipboard
Retrieve of input stream from uri
Link copied to clipboard
Link copied to clipboard
Retrieve of output stream from uri
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun getRecordingDirectory(external: Boolean): String
Link copied to clipboard
Link copied to clipboard
open fun getStorageDirectory(contentType: Int, mediaType: MediaType, storageType: Int): String
Return complete filesystem path of storage directory that used by app according to :
Link copied to clipboard
Link copied to clipboard
open fun getUri(@Nullable file: File): Uri
Retrieve uri of existed file
Link copied to clipboard
@RequiresApi(value = 24)
open fun getVirtualFileSize(@NonNull uri: Uri): Long
Link copied to clipboard
open fun isEmpty(@Nullable file: File): Boolean
Link copied to clipboard
Link copied to clipboard
open fun moveToCache(@NonNull sourceFile: File, @NonNull cachePath: Array<String>): Uri
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun openFileNative(@NonNull filePath: String, create: Boolean): Int
Used from native code Getting access to file by obtaining native file descriptor.
Link copied to clipboard
Release all persistable URI permissions that was taken by app.
Link copied to clipboard
open fun releasePersistableUriPermissions(uris: List<Uri>, modeFlags: Int)
Release certain persistable URI permissions that was taken.
Link copied to clipboard
open fun save(@Nullable sourceUri: Uri, @Nullable targetStream: FileOutputStream): Boolean
Save provided content from provided uri to output stream of existed file.
open fun save(@NonNull bitmap: Bitmap, @NonNull fileName: String, storageType: Int): Uri
Save provided bitmap to file storage as image file.
open fun save(@NonNull file: File, contentType: Int, storageType: Int): Uri
Save provided file to file storage according to :
open fun save(@NonNull sourceUri: Uri, @NonNull fileName: String, contentType: Int, storageType: Int): Uri
Save provided content from uri to file storage according to :
open fun save(bytes: Array<Byte>, @NonNull fileName: String, contentType: Int, storageType: Int): Uri
Save provided byte array to file storage.
open fun save(@NonNull sourceStream: InputStream, @NonNull fileName: String, contentType: Int, storageType: Int): Uri
Save provided input stream data to file storage according to :
Link copied to clipboard
open fun saveToCache(@NonNull bitmap: Bitmap, @NonNull cachePath: Array<String>): Uri
Save content from provided bitmap to cache.
open fun saveToCache(@NonNull sourceUri: Uri, @NonNull cachePath: Array<String>): Uri
Save content from provided uri to cache.
open fun saveToCache(bytes: Array<Byte>, @NonNull cachePath: Array<String>): Uri
Save content from provided byte array to cache.
open fun saveToCache(@NonNull sourceFile: File, @NonNull cachePath: Array<String>): Uri
open fun saveToCache(@NonNull sourceStream: InputStream, @NonNull cachePath: Array<String>): Uri
Link copied to clipboard
open fun saveToPrivateStorage(sourceUri: Uri, fileName: String, contentType: Int): Uri
Save content from provided uri to private storage.
Link copied to clipboard
@RequiresApi(value = 24)
open fun saveVirtualFile(@Nullable sourceUri: Uri, @Nullable targetStream: FileOutputStream): Boolean
Save provided content from provided uri of virtual file (for example virtual files created by Google Drive) to output stream of existed file.
Link copied to clipboard
open fun takePersistableUriPermission(uris: List<Uri>, modeFlags: Int)
Take a persistable URI permission grant that has been offered (for example for URI retrieved using SAF framework with ACTION_OPEN_DOCUMENT).