-
public class FileUtil.StrictMode
Provides strict mode equivalents to methods in FileUtil. Strict mode methods will beexecuted in an io thread, blocking the calling thread until the operation is complete.
-
-
Method Summary
Modifier and Type Method Description static File
makeReadWriteDirectory(@Nullable() File path)
Checks if the specified path is a directory that can be read from and written into. static File
getExternalDirectory(@NonNull() Context context, @Nullable() String folderType, @Nullable() String name)
Gets the path to a directory on the primary shared/external storage device where theapplication can place persistent files it owns. static boolean
delete(@NonNull() File path)
Deletes a file or folder, even if the folder is not empty. static boolean
isFile(@Nullable() String path)
Checks if specified path points to a file that exists on the local filesystem. static boolean
isDirectory(@Nullable() String path)
Checks if specified path points to a directory that exists on the local filesystem. static boolean
exists(@Nullable() String path)
Checks if specified path points to a file/directory that exists on the local filesystem.The operation will be performed on an io thread to adhere to the strict mode policy. -
-
Method Detail
-
makeReadWriteDirectory
@NonNull() static File makeReadWriteDirectory(@Nullable() File path)
Checks if the specified path is a directory that can be read from and written into. If thedirectory does not exist, then this method will try to create a readable/writabledirectory. The operation will be performed on an io thread to adhere to the strict modepolicy. The calling thread will be blocked until the operation is complete.
- Parameters:
path
- the path to check/create.
-
getExternalDirectory
@NonNull() static File getExternalDirectory(@NonNull() Context context, @Nullable() String folderType, @Nullable() String name)
Gets the path to a directory on the primary shared/external storage device where theapplication 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 whetherit 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.
- Parameters:
context
- the contextfolderType
- the type of files directory to return.name
- an optional subfolder name within the selected folder type.
-
delete
static boolean delete(@NonNull() File path)
Deletes a file or folder, even if the folder is not empty. The operation will beperformed on an io thread to adhere to the strict mode policy. The calling thread willbe blocked until the operation is complete.
- Parameters:
path
- the path to be deleted.
-
isFile
static boolean isFile(@Nullable() String path)
Checks if specified path points to a file that exists on the local filesystem. Theoperation will be performed on an io thread to adhere to the strict mode policy. Thecalling thread will be blocked until the operation is complete.
- Parameters:
path
- the string path to be checked.
-
isDirectory
static boolean isDirectory(@Nullable() String path)
Checks if specified path points to a directory that exists on the local filesystem. Theoperation will be performed on an io thread to adhere to the strict mode policy. Thecalling thread will be blocked until the operation is complete.
- Parameters:
path
- the string path to be checked.
-
exists
static boolean exists(@Nullable() String path)
Checks if specified path points to a file/directory that exists on the local filesystem.The operation will be performed on an io thread to adhere to the strict mode policy. Thecalling thread will be blocked until the operation is complete.
- Parameters:
path
- the string path to be checked.
-
-
-
-