public interface Storage
A storage implementation may be obtained via Storage.PROVIDER.getStorage(Context).
Below are listed methods to manage files on the file system provided by the this interface:
createFile(String)createFile(int, String)createFiles(String...)createFiles(int, String...)createDirectory(String)createDirectory(int, String)createDirectories(String...)createDirectories(int, String...)deleteFile(String)deleteFile(int, String)deleteFiles(String...)deleteFiles(int, String...)deleteDirectory(String)deleteDirectory(int, String)deleteDirectory(int, FileFilter, FilenameFilter, String)deleteDirectories(String...)deleteDirectories(int, String...)deleteDirectories(int, FileFilter, FilenameFilter, String...)copyFile(int, String, String)copyFile(int, int, String, String)copyFiles(int, String, String...)copyFiles(int, int, String, String...)copyDirectory(int, String, String)copyDirectory(int, int, String, String)copyDirectory(int, int, FileFilter, FilenameFilter, String, String)copyDirectories(int, String, String...)copyDirectories(int, int, String, String...)copyDirectories(int, int, FileFilter, FilenameFilter, String, String...)moveFile(int, String, String)moveFile(int, int, String, String)moveFiles(int, String, String...)moveFiles(int, int, String, String...)moveDirectory(int, String, String)moveDirectory(int, int, String, String)moveDirectory(int, int, FileFilter, FilenameFilter, String, String)moveDirectories(int, String, String...)moveDirectories(int, int, String, String...)moveDirectories(int, int, FileFilter, FilenameFilter, String, String...)| Modifier and Type | Interface and Description |
|---|---|
static class |
Storage.BaseResult
This class represents the base structure for results which may be returned by this storage API
when invoking some of its methods.
|
static interface |
Storage.FilePermissions
Defines an annotation for determining set of allowed file permission flags.
|
static interface |
Storage.Flags
Defines an annotation for determining set of allowed flags.
|
static interface |
Storage.Provider
Interface for provider that may be used to access implementation of
Storage. |
static class |
Storage.Result
This class represents structure for result which will be returned by this storage API when
invoking some of its methods which accepts only single path as parameter.
|
static class |
Storage.Results
This class represents structure for result which will be returned by this storage API when
invoking some of its methods which accepts set of paths as parameter so when requesting
a bulk storage operation.
|
static interface |
Storage.StorageDir
Defines an annotation for determining set of available storage directories.
|
static class |
Storage.Unit
Represents unit to measure files on an Android device's file system.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ACTION_COPY
Flag identifying copy action on file system.
|
static int |
ACTION_CREATE
Flag identifying create action on file system.
|
static int |
ACTION_DELETE
Flag identifying delete action on file system.
|
static int |
ACTION_MOVE
Flag identifying move action on file system.
|
static int |
BASE
Identifier for base path on an Android device's file system.
|
static int |
CACHE
Identifier for the cache directory of an Android device's file system.
|
static int |
COPY
Copied flag from
StorageEditor.COPY for better access. |
static int |
DATA
Identifier for the data directory of an Android device's file system.
|
static int |
DEFAULT
Copied flag from
StorageEditor.DEFAULT for better access. |
static int |
ERROR_API
Error set to
Storage.Result or Storage.Results when there was requested some
action to be performed by this storage API, but this action failed because of the specified
flags for this action or because of constraints of this storage API. |
static int |
ERROR_DIRECTORY_SAME_AS_FILE
Error set to
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a directory but the destination path points
to a file. |
static int |
ERROR_EMPTY_REQUEST
Error set to
Storage.Result or Storage.Results when there was requested some
storage API action but no paths for such a action were specified. |
static int |
ERROR_FILE_NOT_FOUND
Error set to
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a file which actually does not exists. |
static int |
ERROR_FILE_SAME_AS_DIRECTORY
Error set to
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a file but the destination path points
to a directory. |
static int |
ERROR_IO
Error set to
Storage.Result or Storage.Results when IOException
occurred while performing some of the storage API actions. |
static int |
ERROR_UNSUPPORTED_OPERATION
Error set to
Storage.Result or Storage.Results when there was requested some
action which is not supported by this storage API. |
static int |
EXTERNAL
Identifier for the external directory of an Android device's file system.
|
static int |
EXTERNAL_PACKAGE
Identifier for the external-package directory of an Android device's file system created
especially for the particular Android application on the external file storage at path:
/Android/data/app.package.name/.
|
static int |
INTERNAL
Identifier for the internal directory of an Android device's file system.
|
static int |
KILO
Constant used to increase amount of bits when moving between different storage units by
Storage.Unit. |
static int |
NO_ERROR
Code representing no error.
|
static int |
NO_FLAGS
Represents an empty set of flags for storage API.
|
static int |
OVERWRITE
Copied flag from
StorageEditor.OVERWRITE for better access. |
static int |
PERMISSION_EXECUTE
Flag indicating whether to allow permission to file to be executable or not.
|
static int |
PERMISSION_READ
Flag indicating whether to allow permission to file to be readable or not.
|
static int |
PERMISSION_WRITE
Flag indicating whether to allow permission to file to be writable or not.
|
static int |
PERMISSIONS_ALL
All file permissions.
|
static int |
PERMISSIONS_READ_WRITE
Read + Write file permissions.
|
static Storage.Provider |
PROVIDER
A
Storage.Provider implementation that may be used to access implementation of Storage. |
static int |
ROOT
Identifier for the root directory of an Android device's file system.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
changeFilePermissions(int storage,
String path,
int permissions,
boolean ownerOnly)
Changes read/write permissions of a file on the given path of this Android
device's storage.
|
boolean |
changeFilePermissions(String path,
int permissions,
boolean ownerOnly)
Same as
changeFilePermissions(int, String, int, boolean) for BASE storage. |
Storage.Results |
copyDirectories(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String... fromPaths)
Copies all directories at the given fromPaths on this Android device's storage.
|
Storage.Results |
copyDirectories(int storage,
int flags,
String toPath,
String... fromPaths)
Same as
copyDirectories(int, int, FileFilter, FilenameFilter, String, String...) with
null filters, so whole content of the requested directories will be copied. |
Storage.Results |
copyDirectories(int flags,
String toPath,
String... fromPaths)
Same as
copyDirectories(int, int, String, String...) for BASE storage. |
Storage.Result |
copyDirectory(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String fromPath)
Copies a directory from the given fromPath to the given toPath on this
Android device's storage.
|
Storage.Result |
copyDirectory(int storage,
int flags,
String toPath,
String fromPath)
Same as
copyDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters, so whole content of the requested directory will be copied. |
Storage.Result |
copyDirectory(int flags,
String toPath,
String fromPath)
Same as
copyFile(int, int, String, String) for BASE storage. |
Storage.Result |
copyFile(int storage,
int flags,
String toPath,
String fromPath)
Copies a file from the given fromPath to the given toPath on this Android
device's storage.
|
Storage.Result |
copyFile(int flags,
String toPath,
String fromPath)
Same as
copyFile(int, int, String, String) for BASE storage. |
Storage.Result |
copyFileOrDirectory(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String fromPath)
Performs
copyFile(int, int, String, String) or copyDirectory(int, int, FileFilter, FilenameFilter, String, String)
depends on whether the given fromPath points to a file or to a directory. |
Storage.Result |
copyFileOrDirectory(int storage,
int flags,
String toPath,
String fromPath)
Same as
copyFileOrDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters. |
Storage.Result |
copyFileOrDirectory(int flags,
String toPath,
String fromPath)
Same as
copyFileOrDirectory(int, int, String, String) for BASE storage. |
Storage.Results |
copyFiles(int storage,
int flags,
String toPath,
String... fromPaths)
Copies all files at the given fromPaths on this Android device's storage.
|
Storage.Results |
copyFiles(int flags,
String toPath,
String... fromPaths)
Same as
copyFiles(int, int, String, String...) for BASE storage. |
Storage.Results |
copyFilesOrDirectories(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String... fromPaths)
Performs
copyFile(int, int, String, String) or copyDirectory(int, int, FileFilter, FilenameFilter, String, String)
for each of the given fromPaths depends on whether the iterated path points to a file
or to a directory. |
Storage.Results |
copyFilesOrDirectories(int storage,
int flags,
String toPath,
String... fromPaths)
Same as
copyFilesOrDirectories(int, int, FileFilter, FilenameFilter, String, String...)
with null filters. |
Storage.Results |
copyFilesOrDirectories(int flags,
String toPath,
String... fromPaths)
Same as
copyFilesOrDirectories(int, int, String, String...) for BASE storage. |
Storage.Results |
createDirectories(int storage,
String... paths)
Creates all directories with the given paths on this Android device's storage.
|
Storage.Results |
createDirectories(String... paths)
Same as
createDirectories(int, String...) for BASE storage. |
Storage.Result |
createDirectory(int storage,
String path)
Creates a directory with the given path on this Android device's storage.
|
Storage.Result |
createDirectory(String path)
Same as
createDirectory(int, String) for BASE storage. |
Storage.Result |
createFile(int storage,
String path)
Creates a file with the given path on this Android device's storage.
|
Storage.Result |
createFile(String path)
Same as
createFile(int, String) for BASE storage. |
Storage.Results |
createFiles(int storage,
String... paths)
Creates all files with the given paths on this Android device's storage.
|
Storage.Results |
createFiles(String... paths)
Same as
createFiles(int, String...) for BASE storage. |
Storage.Results |
deleteDirectories(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String... paths)
Deletes all directories at the given paths from this Android device's storage.
|
Storage.Results |
deleteDirectories(int storage,
String... paths)
Same as
deleteDirectories(int, FileFilter, FilenameFilter, String...) with null
filters. |
Storage.Results |
deleteDirectories(String... paths)
Same as
deleteDirectories(int, String...) for BASE storage. |
Storage.Result |
deleteDirectory(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String path)
Deletes a directory at the given path from this Android device's storage.
|
Storage.Result |
deleteDirectory(int storage,
String path)
Same as
deleteDirectory(int, FileFilter, FilenameFilter, String) with null
filters. |
Storage.Result |
deleteDirectory(String path)
Same as
deleteDirectory(int, String) for BASE storage. |
Storage.Result |
deleteFile(int storage,
String path)
Deletes a file at the given path from this Android device's storage.
|
Storage.Result |
deleteFile(String path)
Same as
deleteFile(int, String) for BASE storage. |
Storage.Result |
deleteFileOrDirectory(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String path)
Performs
deleteFile(int, String) or deleteDirectory(int, FileFilter, FilenameFilter, String)
depends on whether the given path points to a file or to a directory. |
Storage.Result |
deleteFileOrDirectory(int storage,
String path)
Same as
deleteFileOrDirectory(int, FileFilter, FilenameFilter, String) with
null filters. |
Storage.Result |
deleteFileOrDirectory(String path)
Same as
deleteFileOrDirectory(int, String) for BASE storage. |
Storage.Results |
deleteFiles(int storage,
String... paths)
Deletes all files at the given paths from this Android device's storage.
|
Storage.Results |
deleteFiles(String... paths)
Same as
deleteFiles(int, String...) for BASE storage. |
Storage.Results |
deleteFilesOrDirectories(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String... paths)
Performs
deleteFile(int, String) or deleteDirectory(int, FileFilter, FilenameFilter, String)
for each of the given paths depends on whether the iterated path points to a file
or to a directory. |
Storage.Results |
deleteFilesOrDirectories(int storage,
String... paths)
Same as
deleteFilesOrDirectories(int, FileFilter, FilenameFilter, String...) with
null filters. |
Storage.Results |
deleteFilesOrDirectories(String... paths)
Same as
deleteFilesOrDirectories(int, String...) for BASE storage. |
List<File> |
getDirectoriesContent(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String... paths)
Lists all files stored within directories at the given paths on this Android
device's storage.
|
List<File> |
getDirectoriesContent(int storage,
String... paths)
Same as
getDirectoriesContent(int, FileFilter, FilenameFilter, String...)
with null filters. |
List<File> |
getDirectoriesContent(String... paths)
Same as
getDirectoriesContent(int, String...) for BASE storage. |
List<File> |
getDirectoryContent(int storage,
FileFilter filter,
FilenameFilter nameFilter,
String path)
Lists all files stored within a directory at the given path on this Android device's
storage.
|
List<File> |
getDirectoryContent(int storage,
String path)
Same as
getDirectoryContent(int, FileFilter, FilenameFilter, String)
with null filters. |
List<File> |
getDirectoryContent(String path)
Same as
getDirectoryContent(int, String) for BASE storage. |
File |
getFile(int storage,
String path)
Returns a file eventually stored on the specified storage.
|
long |
getFreeSpace(int storage)
Returns the currently available free space on the requested storage type.
|
File |
getStorage(int storage)
Returns a file representing the directory on this Android device's file system.
|
String |
getStoragePath(int storage)
Returns a path obtained from the requested storage by
getStorage(int).getPath(). |
boolean |
hasFreeSpace(int storage,
long bytes)
Checks whether there is the specified amount of bytes available on the requested
storage type.
|
boolean |
isExternalAvailable()
Checks whether there is some external storage available on this Android device which can be
used to store some data.
|
boolean |
isExternalMounted()
Checks whether there is some external storage mounted to this Android device or not.
|
boolean |
isExternalReadOnly()
Checks whether the current mounted external storage is in read only state or not.
|
Storage.Results |
moveDirectories(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String... fromPaths)
Moves all directories at the given fromPaths on this Android device's storage.
|
Storage.Results |
moveDirectories(int storage,
int flags,
String toPath,
String... fromPaths)
Same as
moveDirectories(int, int, FileFilter, FilenameFilter, String, String...) with
null filters, so whole content of the requested directories will be copied. |
Storage.Results |
moveDirectories(int flags,
String toPath,
String... fromPaths)
Same as
moveDirectories(int, int, String, String...) for BASE storage. |
Storage.Result |
moveDirectory(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String fromPath)
Moves a directory from the given fromPath to the given toPath on this
Android device's storage.
|
Storage.Result |
moveDirectory(int storage,
int flags,
String toPath,
String fromPath)
Same as
moveDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters, so whole content of the requested directory will be copied. |
Storage.Result |
moveDirectory(int flags,
String toPath,
String fromPath)
Same as
moveFile(int, int, String, String) for BASE storage. |
Storage.Result |
moveFile(int storage,
int flags,
String toPath,
String fromPath)
Moves a file from the given fromPath to the given toPath on this Android
device's storage.
|
Storage.Result |
moveFile(int flags,
String toPath,
String fromPath)
Same as
moveFile(int, int, String, String) for BASE storage. |
Storage.Result |
moveFileOrDirectory(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String fromPath)
Performs
moveFile(int, int, String, String) or moveDirectory(int, int, FileFilter, FilenameFilter, String, String)
depends on whether the given fromPath points to a file or to a directory. |
Storage.Result |
moveFileOrDirectory(int storage,
int flags,
String toPath,
String fromPath)
Same as
moveFileOrDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters. |
Storage.Result |
moveFileOrDirectory(int flags,
String toPath,
String fromPath)
Same as
moveFileOrDirectory(int, int, String, String) for BASE storage. |
Storage.Results |
moveFiles(int storage,
int flags,
String toPath,
String... fromPaths)
Moves all files at the given fromPaths on this Android device's storage.
|
Storage.Results |
moveFiles(int flags,
String toPath,
String... fromPaths)
Same as
moveFiles(int, int, String, String...) for BASE storage. |
Storage.Results |
moveFilesOrDirectories(int storage,
int flags,
FileFilter filter,
FilenameFilter nameFilter,
String toPath,
String... fromPaths)
Performs
moveFile(int, int, String, String) or moveDirectory(int, int, FileFilter, FilenameFilter, String, String)
for each of the given fromPaths depends on whether the iterated path points to a file
or to a directory. |
Storage.Results |
moveFilesOrDirectories(int storage,
int flags,
String toPath,
String... fromPaths)
Same as
moveFilesOrDirectories(int, int, FileFilter, FilenameFilter, String, String...)
with null filters. |
Storage.Results |
moveFilesOrDirectories(int flags,
String toPath,
String... fromPaths)
Same as
moveFilesOrDirectories(int, int, String, String...) for BASE storage. |
static final Storage.Provider PROVIDER
Storage.Provider implementation that may be used to access implementation of Storage.static final int NO_FLAGS
Storage.Result objects when there are used storage API methods which does not takes
any flags.static final int DEFAULT
StorageEditor.DEFAULT for better access.static final int OVERWRITE
StorageEditor.OVERWRITE for better access.static final int COPY
StorageEditor.COPY for better access.static final int PERMISSION_READ
static final int PERMISSION_WRITE
static final int PERMISSION_EXECUTE
static final int PERMISSIONS_READ_WRITE
static final int PERMISSIONS_ALL
static final int BASE
static final int ROOT
Note, that this is only read-only file storage.
See Environment.getRootDirectory() for additional info.
static final int DATA
See Environment.getDataDirectory() for additional info.
static final int CACHE
Note, that this directory is created for each of Android applications (respectively), identified by theirs package name, and is meant to be used for caching all necessary data of the particular Android application. This directory can be accessed/managed only by application for which was this directory created.
Files from this directory will be deleted as first when the Android device runs low on storage.
Once the application is uninstalled, this directory will be deleted.
See Context.getCacheDir() for additional info.
static final int INTERNAL
Note, that this directory (like CACHE) is created for each of Android applications
(respectively), and is meant to be used for storing all necessary data of the particular Android
application.
Once the application is uninstalled, this directory will be deleted.
See Context.getFilesDir() for additional info.
static final int EXTERNAL
See Environment.getExternalStorageDirectory() for additional info.
isExternalAvailable(),
Constant Field Valuesstatic final int EXTERNAL_PACKAGE
Note, that this directory is created when getStorage(EXTERNAL_PACKAGE)
is being first time called and the external storage is at that particular time available.
isExternalAvailable(),
Constant Field Valuesstatic final int ACTION_CREATE
This flag is used by Storage.Result and Storage.Results to identify for which
action was the specific result created.
static final int ACTION_DELETE
This flag is used by Storage.Result and Storage.Results to identify for which
action was the specific result created.
static final int ACTION_COPY
This flag is used by Storage.Result and Storage.Results to identify for which
action was the specific result created.
static final int ACTION_MOVE
This flag is used by Storage.Result and Storage.Results to identify for which
action was the specific result created.
static final int NO_ERROR
static final int ERROR_EMPTY_REQUEST
Storage.Result or Storage.Results when there was requested some
storage API action but no paths for such a action were specified.
Constant value: 0
static final int ERROR_IO
Storage.Result or Storage.Results when IOException
occurred while performing some of the storage API actions.
Constant value: -1
static final int ERROR_UNSUPPORTED_OPERATION
Storage.Result or Storage.Results when there was requested some
action which is not supported by this storage API.
This can be for example, when trying to move directory to itself.
Constant value: -2
static final int ERROR_API
Storage.Result or Storage.Results when there was requested some
action to be performed by this storage API, but this action failed because of the specified
flags for this action or because of constraints of this storage API.
This can be for example when requesting copy action for some files which should be copied
into the same directory as they are right now, but without COPY flag.
Constant value: -3
static final int ERROR_FILE_NOT_FOUND
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a file which actually does not exists.
Constant value: -17
static final int ERROR_FILE_SAME_AS_DIRECTORY
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a file but the destination path points
to a directory.
This can be for example, when trying to copy a file to another directory where in this particular directory already exists a directory with the same name as the requested file.
Constant value: -18
static final int ERROR_DIRECTORY_SAME_AS_FILE
Storage.Result or Storage.Results whenever there is requested
some action to be performed by this storage API with a directory but the destination path points
to a file.
This can be for example, when trying to move a directory to another directory where in this particular directory already exists a file with the same name as the requested directory.
Constant value: -19
static final int KILO
Storage.Unit.Storage.Result createFile(String path)
createFile(int, String) for BASE storage.Storage.Result createFile(int storage, String path)
See StorageUtils.createFile(String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file which should be created.path - The path to the file which should be created.Storage.Results createFiles(String... paths)
createFiles(int, String...) for BASE storage.Storage.Results createFiles(int storage, String... paths)
This is a bulk operation for createFile(int, String) method, so the given paths will
be looped to perform the requested action for each of them.
paths - Set of paths of files which should be created.Storage.Result createDirectory(String path)
createDirectory(int, String) for BASE storage.Storage.Result createDirectory(int storage, String path)
See StorageUtils.createDirectory(String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the directory which should be created.path - The path to the directory which should be created.Storage.Results createDirectories(String... paths)
createDirectories(int, String...) for BASE storage.Storage.Results createDirectories(int storage, String... paths)
This is a bulk operation for createDirectory(int, String) method, so the given paths
will be looped to perform the requested action for each of them.
paths - Set of paths of directories which should be created.Storage.Result deleteFile(String path)
deleteFile(int, String) for BASE storage.Storage.Result deleteFile(int storage, String path)
See StorageUtils.deleteFile(String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file which should be deleted.path - The path to the file which should be deleted.Storage.Results deleteFiles(String... paths)
deleteFiles(int, String...) for BASE storage.Storage.Results deleteFiles(int storage, String... paths)
This is a bulk operation for deleteFile(int, String) method, so the given paths will
be looped to perform the requested action for each of them.
paths - Set of paths to files which should be deleted.Storage.Result deleteDirectory(String path)
deleteDirectory(int, String) for BASE storage.Storage.Result deleteDirectory(int storage, String path)
deleteDirectory(int, FileFilter, FilenameFilter, String) with null
filters.Storage.Result deleteDirectory(int storage, FileFilter filter, FilenameFilter nameFilter, String path)
Note, that if this method is used with valid filters, sub-directories (and theirs sub-directories, ...) of the requested directory which has some content left after deleting process will remain and will be not deleted. This also applies to the requested directory. This can be used to not delete whole directory, but only the desired files of such a directory.
See StorageUtils.deleteDirectory(FileFilter, FilenameFilter, String) for additional
info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file which should be deleted.filter - If not null, this filter will be used to delete only files of
the requested directory which passes through this filter, all other files
will be not deleted.nameFilter - If not null, this filter will be used to delete only files of
the requested directory with names which passes through this filter, all
other files will be not deleted.path - The path to the directory which should be deleted or of which filtered files
should be deleted.Storage.Results deleteDirectories(String... paths)
deleteDirectories(int, String...) for BASE storage.Storage.Results deleteDirectories(int storage, String... paths)
deleteDirectories(int, FileFilter, FilenameFilter, String...) with null
filters.Storage.Results deleteDirectories(int storage, FileFilter filter, FilenameFilter nameFilter, String... paths)
This is a bulk operation for deleteDirectory(int, FileFilter, FilenameFilter, String)
method, so the given paths will be looped to perform the requested action for each of them.
paths - Set of paths to directories which should be deleted.Storage.Result deleteFileOrDirectory(String path)
deleteFileOrDirectory(int, String) for BASE storage.Storage.Result deleteFileOrDirectory(int storage, String path)
deleteFileOrDirectory(int, FileFilter, FilenameFilter, String) with
null filters.Storage.Result deleteFileOrDirectory(int storage, FileFilter filter, FilenameFilter nameFilter, String path)
deleteFile(int, String) or deleteDirectory(int, FileFilter, FilenameFilter, String)
depends on whether the given path points to a file or to a directory.Storage.Results deleteFilesOrDirectories(String... paths)
deleteFilesOrDirectories(int, String...) for BASE storage.Storage.Results deleteFilesOrDirectories(int storage, String... paths)
deleteFilesOrDirectories(int, FileFilter, FilenameFilter, String...) with
null filters.Storage.Results deleteFilesOrDirectories(int storage, FileFilter filter, FilenameFilter nameFilter, String... paths)
deleteFile(int, String) or deleteDirectory(int, FileFilter, FilenameFilter, String)
for each of the given paths depends on whether the iterated path points to a file
or to a directory.Storage.Result copyFile(int flags, String toPath, String fromPath)
copyFile(int, int, String, String) for BASE storage.Storage.Result copyFile(int storage, int flags, String toPath, String fromPath)
See StorageUtils.deleteFile(String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file which should be copied.flags - Set of flags to be taken into count when performing this action. Use for example
COPY flag to create copy at the same path as the specified fromPath
with -Copy suffix.toPath - The path to the file where should be the requested file copied. If there is no
existing file at this path, a new one will be created.fromPath - The path to the file which should be copied.Storage.Results copyFiles(int flags, String toPath, String... fromPaths)
copyFiles(int, int, String, String...) for BASE storage.Storage.Results copyFiles(int storage, int flags, String toPath, String... fromPaths)
This is a bulk operation for copyFile(int, int, String, String) method, so the given
paths will be looped to perform the requested action for each of them.
fromPaths - Set of paths to files which should be copied.Storage.Result copyDirectory(int flags, String toPath, String fromPath)
copyFile(int, int, String, String) for BASE storage.Storage.Result copyDirectory(int storage, int flags, String toPath, String fromPath)
copyDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters, so whole content of the requested directory will be copied.Storage.Result copyDirectory(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String fromPath)
Note, that if this method is used with valid filters, only files which passes the given filters will be copied to the requested destination. This can be used to not copy whole directory, but only the desired files of such a directory.
See StorageUtils.copyDirectory(int, FileFilter, FilenameFilter, String, String) for
additional info.
storage - An identifier of the storage of which path to use as base path for
the given paths. Use BASE when the given paths represents full paths
for the directory which should be copied.flags - Set of flags to be taken into count when performing this action. Use for example
COPY flag to create copy at the same path as the specified fromPath
with -Copy suffix.filter - If not null, this filter will be used to copy only files of the
requested directory which passes through this filter, all other files will
be not copied.nameFilter - If not null, this filter will be used to copy only files of the
requested directory with names which passes through this filter, all other
files will be not copied.toPath - The path to the directory where should be the requested directory or its filtered
files copied. If there is no existing directory at this path, a new one will
be created.fromPath - The path to the directory which or of which filtered files should be copied.Storage.Results copyDirectories(int flags, String toPath, String... fromPaths)
copyDirectories(int, int, String, String...) for BASE storage.Storage.Results copyDirectories(int storage, int flags, String toPath, String... fromPaths)
copyDirectories(int, int, FileFilter, FilenameFilter, String, String...) with
null filters, so whole content of the requested directories will be copied.Storage.Results copyDirectories(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String... fromPaths)
This is a bulk operation for copyDirectory(int, int, FileFilter, FilenameFilter, String, String)
method, so the given paths will be looped to perform the requested action for each of them.
fromPaths - Set of paths to directories which should be copied.Storage.Result copyFileOrDirectory(int flags, String toPath, String fromPath)
copyFileOrDirectory(int, int, String, String) for BASE storage.Storage.Result copyFileOrDirectory(int storage, int flags, String toPath, String fromPath)
copyFileOrDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters.Storage.Result copyFileOrDirectory(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String fromPath)
copyFile(int, int, String, String) or copyDirectory(int, int, FileFilter, FilenameFilter, String, String)
depends on whether the given fromPath points to a file or to a directory.Storage.Results copyFilesOrDirectories(int flags, String toPath, String... fromPaths)
copyFilesOrDirectories(int, int, String, String...) for BASE storage.Storage.Results copyFilesOrDirectories(int storage, int flags, String toPath, String... fromPaths)
copyFilesOrDirectories(int, int, FileFilter, FilenameFilter, String, String...)
with null filters.Storage.Results copyFilesOrDirectories(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String... fromPaths)
copyFile(int, int, String, String) or copyDirectory(int, int, FileFilter, FilenameFilter, String, String)
for each of the given fromPaths depends on whether the iterated path points to a file
or to a directory.Storage.Result moveFile(int flags, String toPath, String fromPath)
moveFile(int, int, String, String) for BASE storage.Storage.Result moveFile(int storage, int flags, String toPath, String fromPath)
See StorageUtils.moveFile(int, String, String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file which should be copied.flags - Set of flags to be taken into count when performing this action. Use for example
OVERWRITE flag to overwrite the existing file at the specified toPath.toPath - The path to the file where should be the requested file copied. If there is no
existing file at this path, a new one will be created.fromPath - The path to the file which should be copied.Storage.Results moveFiles(int flags, String toPath, String... fromPaths)
moveFiles(int, int, String, String...) for BASE storage.Storage.Results moveFiles(int storage, int flags, String toPath, String... fromPaths)
This is a bulk operation for moveFile(int, int, String, String) method, so the given
paths will be looped to perform the requested action for each of them.
fromPaths - Set of paths to files which should be moved.Storage.Result moveDirectory(int flags, String toPath, String fromPath)
moveFile(int, int, String, String) for BASE storage.Storage.Result moveDirectory(int storage, int flags, String toPath, String fromPath)
moveDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters, so whole content of the requested directory will be copied.Storage.Result moveDirectory(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String fromPath)
Note, that if this method is used with valid filters, only files which passes the given filters will be moved to the requested destination. This can be used to not move whole directory, but only the desired files of such a directory.
See StorageUtils.moveDirectory(int, String, String) for additional info.
storage - An identifier of the storage of which path to use as base path for
the given paths. Use BASE when the given paths represents full paths
for the directory which should be copied.flags - Set of flags to be taken into count when performing this action. Use for example
OVERWRITE flag to overwrite the existing directory at the specified
toPath.filter - If not null, this filter will be used to move only files of the
requested directory which passes through this filter, all other files will
be not moved.nameFilter - If not null, this filter will be used to move only files of the
requested directory with names which passes through this filter, all other
files will be not moved.toPath - The path to the directory where should be the requested directory or its filtered
files copied. If there is no existing directory at this path, a new one will
be created.fromPath - The path to the directory which or of which filtered files should be moved.Storage.Results moveDirectories(int flags, String toPath, String... fromPaths)
moveDirectories(int, int, String, String...) for BASE storage.Storage.Results moveDirectories(int storage, int flags, String toPath, String... fromPaths)
moveDirectories(int, int, FileFilter, FilenameFilter, String, String...) with
null filters, so whole content of the requested directories will be copied.Storage.Results moveDirectories(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String... fromPaths)
This is a bulk operation for moveFile(int, int, String, String) method, so the given
paths will be looped to perform the requested action for each of them.
fromPaths - Set of paths to directories which should be moved.Storage.Result moveFileOrDirectory(int flags, String toPath, String fromPath)
moveFileOrDirectory(int, int, String, String) for BASE storage.Storage.Result moveFileOrDirectory(int storage, int flags, String toPath, String fromPath)
moveFileOrDirectory(int, int, FileFilter, FilenameFilter, String, String) with
null filters.Storage.Result moveFileOrDirectory(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String fromPath)
moveFile(int, int, String, String) or moveDirectory(int, int, FileFilter, FilenameFilter, String, String)
depends on whether the given fromPath points to a file or to a directory.Storage.Results moveFilesOrDirectories(int flags, String toPath, String... fromPaths)
moveFilesOrDirectories(int, int, String, String...) for BASE storage.Storage.Results moveFilesOrDirectories(int storage, int flags, String toPath, String... fromPaths)
moveFilesOrDirectories(int, int, FileFilter, FilenameFilter, String, String...)
with null filters.Storage.Results moveFilesOrDirectories(int storage, int flags, FileFilter filter, FilenameFilter nameFilter, String toPath, String... fromPaths)
moveFile(int, int, String, String) or moveDirectory(int, int, FileFilter, FilenameFilter, String, String)
for each of the given fromPaths depends on whether the iterated path points to a file
or to a directory.boolean changeFilePermissions(String path, int permissions, boolean ownerOnly)
changeFilePermissions(int, String, int, boolean) for BASE storage.boolean changeFilePermissions(int storage,
String path,
int permissions,
boolean ownerOnly)
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents
full path to the file of which read/write permissions should be changed.path - The path to the file of which permissions should be changed.permissions - The desired read/write/execute permissions. One of PERMISSION_READ,
PERMISSION_WRITE, PERMISSION_EXECUTE or combination of
them.ownerOnly - If true only owner will have the specified permissions, otherwise
any one will have them.True if all permissions were successfully changed, false
otherwise.boolean isExternalMounted()
true, the current external storage can be used for read + write
access.
See Environment.getExternalStorageState() and Environment.MEDIA_MOUNTED
for more info.
True if some external storage is mounted to this Android device,
false otherwise.isExternalReadOnly(),
isExternalAvailable()boolean isExternalReadOnly()
See Environment.getExternalStorageState() and Environment.MEDIA_MOUNTED_READ_ONLY
for more info.
True if the currently mounted external storage to this Android device is
in read only state, false if there is no external storage mounted or the
current one can be used for read + write operations.isExternalMounted(),
isExternalAvailable()boolean isExternalAvailable()
True if there is some external storage mounted and can be used for
read + write access or at least for read access if it is in Environment.MEDIA_MOUNTED_READ_ONLY
state.isExternalMounted(),
isExternalReadOnly()boolean hasFreeSpace(int storage,
long bytes)
Note, that for BASE this will always returns false, because this
identifier doesn't represents any storage.
See File.getFreeSpace() for additional info.
storage - An identifier of the storage of which free space to check.bytes - The desired amount of bytes to check against.True if there is at least the desired amount of bytes available for storing
of new files on the requested storage, false otherwise.long getFreeSpace(int storage)
Note, that for BASE this will always returns 0, because this
identifier doesn't represents any storage.
storage - An identifier of the storage of which free space to obtain.File getStorage(int storage)
Note, that for BASE this will always returns null, because this
identifier doesn't represents any storage.
storage - An identifier of the storage of which directory to obtain.null unknown storage type was
requested.String getStoragePath(int storage)
getStorage(int).getPath().File getFile(int storage, String path)
Note, that this method only builds the path to the requested file and creates an instance of File.
storage - An identifier of the storage of which path to use as base path for the requested
file.path - Relative path to the desired file which is stored at storage with the specified
identifier.List<File> getDirectoryContent(String path)
getDirectoryContent(int, String) for BASE storage.List<File> getDirectoryContent(int storage, String path)
getDirectoryContent(int, FileFilter, FilenameFilter, String)
with null filters.List<File> getDirectoryContent(int storage, FileFilter filter, FilenameFilter nameFilter, String path)
See File.listFiles(FileFilter) and File.listFiles(FilenameFilter)
for additional info.
storage - An identifier of the storage of which path to use as base path for
the given path. Use BASE when the given path represents full path
to the directory of which files to list.filter - If not null, this filter will be used to filter the desired
types of files.nameFilter - If not null, this filter will be used to filter the desired
files by their names.path - The path to the directory of which files to list.List<File> getDirectoriesContent(String... paths)
getDirectoriesContent(int, String...) for BASE storage.List<File> getDirectoriesContent(int storage, String... paths)
getDirectoriesContent(int, FileFilter, FilenameFilter, String...)
with null filters.List<File> getDirectoriesContent(int storage, FileFilter filter, FilenameFilter nameFilter, String... paths)
This is a bulk operation for getDirectoryContent(int, FileFilter, FilenameFilter, String)
method, so the given paths will be looped to perform the requested action for each of them.
paths - Set of paths to directories of which files should be listed.getDirectoryContent(int, FileFilter, FilenameFilter, String)
for each of the given paths.