Constructor and Description |
---|
StrictMode() |
Modifier and Type | Method and Description |
---|---|
static boolean |
delete(java.io.File path)
Deletes a file or folder, even if the folder is not empty.
|
static boolean |
exists(java.lang.String path)
Checks if specified path points to a file/directory that exists on the local filesystem.
|
static java.io.File |
getExternalDirectory(android.content.Context context,
java.lang.String folderType,
java.lang.String name)
Gets the path to a directory on the primary shared/external storage device where the
application can place persistent files it owns.
|
static boolean |
isDirectory(java.lang.String path)
Checks if specified path points to a directory that exists on the local filesystem.
|
static boolean |
isFile(java.lang.String path)
Checks if specified path points to a file that exists on the local filesystem.
|
static java.io.File |
makeReadWriteDirectory(java.io.File path)
Checks if the specified path is a directory that can be read from and written into.
|
@NonNull public static java.io.File makeReadWriteDirectory(@Nullable java.io.File path)
path
- the path to check/create.java.lang.IllegalArgumentException
- if the download path is invalid or if the download path does
not have read or write permissions.@NonNull public static java.io.File getExternalDirectory(@NonNull android.content.Context context, @Nullable java.lang.String folderType, @Nullable java.lang.String name)
Gets the path to a directory on the primary shared/external storage device where the application can place persistent files it owns. These files are internal to the applications, and not typically visible to the user as media.
Please note that this method will neither check if selected directory exists nor whether it is readable or writable.
The operation will be performed on an io thread to adhere to the strict mode policy. The calling thread will be blocked until the operation is complete.
context
- the contextfolderType
- the type of files directory to return. May be null for the root of the
files directory or one of the following constants for a subdirectory:
Environment.DIRECTORY_MUSIC
,
Environment.DIRECTORY_PODCASTS
,
Environment.DIRECTORY_RINGTONES
,
Environment.DIRECTORY_ALARMS
,
Environment.DIRECTORY_NOTIFICATIONS
,
Environment.DIRECTORY_PICTURES
, or
Environment.DIRECTORY_MOVIES
.name
- an optional subfolder name within the selected folder type.makeReadWriteDirectory(File)
public static boolean delete(@NonNull java.io.File path)
path
- the path to be deleted.public static boolean isFile(@Nullable java.lang.String path)
path
- the string path to be checked.public static boolean isDirectory(@Nullable java.lang.String path)
path
- the string path to be checked.public static boolean exists(@Nullable java.lang.String path)
path
- the string path to be checked.