Package com.brightcove.player.util
Class FileUtil.StrictMode
java.lang.Object
com.brightcove.player.util.FileUtil.StrictMode
- Enclosing class:
- FileUtil
Provides strict mode equivalents to methods in
FileUtil
. Strict mode methods will be
executed in an io thread, blocking the calling thread until the operation is complete.-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Deletes a file or folder, even if the folder is not empty.static boolean
Checks if specified path points to a file/directory that exists on the local filesystem.static File
getExternalDirectory
(android.content.Context context, String folderType, 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
(String path) Checks if specified path points to a directory that exists on the local filesystem.static boolean
Checks if specified path points to a file that exists on the local filesystem.static File
makeReadWriteDirectory
(File path) Checks if the specified path is a directory that can be read from and written into.
-
Constructor Details
-
StrictMode
public StrictMode()
-
-
Method Details
-
makeReadWriteDirectory
Checks if the specified path is a directory that can be read from and written into. If the directory does not exist, then this method will try to create a readable/writable directory. 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:
path
- the path to check/create.- Returns:
- reference to the validated path.
- Throws:
IllegalArgumentException
- if the download path is invalid or if the download path does not have read or write permissions.
-
getExternalDirectory
@NonNull public static File getExternalDirectory(@NonNull android.content.Context context, @Nullable String folderType, @Nullable 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.
- Parameters:
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
, orEnvironment.DIRECTORY_MOVIES
.name
- an optional subfolder name within the selected folder type.- Returns:
- the path to the selected directory.
- See Also:
-
delete
Deletes a file or folder, even if the folder is not empty. 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:
path
- the path to be deleted.- Returns:
- false if the file or folder was found, but could not be deleted.
-
isFile
Checks if specified path points to a file that exists on the local filesystem. 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:
path
- the string path to be checked.- Returns:
- true is the path points to a local file.
-
isDirectory
Checks if specified path points to a directory that exists on the local filesystem. 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:
path
- the string path to be checked.- Returns:
- true is the path points to a local directory.
-
exists
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. The calling thread will be blocked until the operation is complete.- Parameters:
path
- the string path to be checked.- Returns:
- true is the path points to a local file or directory.
-