Package com.mku.android.fs.file
Class AndroidFile
java.lang.Object
com.mku.android.fs.file.AndroidFile
- All Implemented Interfaces:
IFile
Implementation of the IFile for Android using Storage Access Framework that supports read/write to external SD cards.
This class is used by the AndroidDrive implementation so you can use AesFile wrapper transparently
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.mku.fs.file.IFile
IFile.CopyContentsOptions, IFile.CopyOptions, IFile.MoveOptions, IFile.RecursiveCopyOptions, IFile.RecursiveDeleteOptions, IFile.RecursiveMoveOptions -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe directory separatorstatic final StringThe Uri separatorFields inherited from interface com.mku.fs.file.IFile
autoRename -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAndroidFile(AndroidFile parent, String name) Construct an AndroidFile.AndroidFile(DocumentFile documentFile) Construct an AndroidFile wrapper from an Android DocumentFile.protectedAndroidFile(DocumentFile documentFile, AndroidFile parent) Construct an AndroidFile wrapper from an Android DocumentFile. -
Method Summary
Modifier and TypeMethodDescriptionCopy this file to another directory.copy(IFile newDir, IFile.CopyOptions options) Copy this file to another directory with a new filename with a progress.createDirectory(String dirName) Create a directory under this directory.createFile(String filename) Create an empty file under this directory.booleandelete()Delete this file.booleanexists()Check if file exists.Get a child file or directory under this directory.intGet the count of files and subdirectoriesGet the user credentialsGet the display path on the physical drive.ParcelFileDescriptorgetFileDescriptor(String mode) Get a file descriptor corresponding to this file.Get a stream for reading.longGet the last modified date in milliseconds.longGet the size of the file.getName()Get the base name of this file.Get a stream for writing.Get the parent directory.getPath()Get the path on the physical disk.booleanCheck if this is a directory.booleanisFile()Check if this is a file.IFile[]List files and directories.booleanmkdir()Create this directory.Move this file to another directory.move(IFile newDir, IFile.MoveOptions options) Move this file to another directory.booleanRename this file.voidreset()Clear cache properties.toString()Returns a string representation of this objectMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.mku.fs.file.IFile
copyRecursively, copyRecursively, deleteRecursively, deleteRecursively, moveRecursively, moveRecursively
-
Field Details
-
separator
The directory separator- See Also:
-
uriSeparator
The Uri separator- See Also:
-
-
Constructor Details
-
AndroidFile
public AndroidFile(DocumentFile documentFile) Construct an AndroidFile wrapper from an Android DocumentFile.- Parameters:
documentFile- The Android DocumentFile that will be associated to
-
AndroidFile
Construct an AndroidFile wrapper from an Android DocumentFile.- Parameters:
documentFile- The Android DocumentFile that will be associated toparent- The parent if available
-
AndroidFile
Construct an AndroidFile.- Parameters:
parent- The parent file.name- The file name.
-
-
Method Details
-
createDirectory
Create a directory under this directory.- Specified by:
createDirectoryin interfaceIFile- Parameters:
dirName- The directory name.- Returns:
- The new directory.
-
createFile
Create an empty file under this directory.- Specified by:
createFilein interfaceIFile- Parameters:
filename- The file name.- Returns:
- The new file.
-
delete
public boolean delete()Delete this file. -
exists
public boolean exists()Check if file exists. -
getDisplayPath
Get the display path on the physical drive.- Specified by:
getDisplayPathin interfaceIFile- Returns:
- The display path
-
getName
Get the base name of this file. -
getInputStream
Get a stream for reading.- Specified by:
getInputStreamin interfaceIFile- Returns:
- The input stream
- Throws:
FileNotFoundException- Thrown if file is not found
-
getOutputStream
Get a stream for writing.- Specified by:
getOutputStreamin interfaceIFile- Returns:
- The output stream
- Throws:
FileNotFoundException- Thrown if file not found
-
getParent
Get the parent directory. -
getPath
Get the path on the physical disk. -
isDirectory
public boolean isDirectory()Check if this is a directory.- Specified by:
isDirectoryin interfaceIFile- Returns:
- True if directory
-
isFile
public boolean isFile()Check if this is a file. -
getLastDateModified
public long getLastDateModified()Get the last modified date in milliseconds.- Specified by:
getLastDateModifiedin interfaceIFile- Returns:
- Last modified date in milliseconds.
-
getLength
public long getLength()Get the size of the file. -
getChildrenCount
public int getChildrenCount()Get the count of files and subdirectories- Specified by:
getChildrenCountin interfaceIFile- Returns:
- The children count
-
listFiles
List files and directories. -
move
Move this file to another directory.- Specified by:
movein interfaceIFile- Parameters:
newDir- The target directory.- Returns:
- The moved file
- Throws:
IOException- Thrown if error during IO
-
move
Move this file to another directory.- Specified by:
movein interfaceIFile- Parameters:
newDir- The target directory.options- The options.- Returns:
- The moved file
- Throws:
IOException- Thrown if error during IO
-
copy
Copy this file to another directory.- Specified by:
copyin interfaceIFile- Parameters:
newDir- The target directory.- Returns:
- The new file
- Throws:
IOException- Thrown if error during IO
-
copy
Copy this file to another directory with a new filename with a progress.- Specified by:
copyin interfaceIFile- Parameters:
newDir- The target directory.options- The options- Returns:
- The new file
- Throws:
IOException- Thrown if error during IO
-
getChild
Get a child file or directory under this directory. -
renameTo
Rename this file.- Specified by:
renameToin interfaceIFile- Parameters:
newFilename- The new filename- Returns:
- True if file renamed
- Throws:
FileNotFoundException- Thrown if file is not found
-
mkdir
public boolean mkdir()Create this directory. -
reset
public void reset()Clear cache properties. -
getCredentials
Get the user credentials- Specified by:
getCredentialsin interfaceIFile- Returns:
- The credentials
-
getFileDescriptor
Get a file descriptor corresponding to this file.- Parameters:
mode- The mode- Returns:
- The parcel file descriptor
- Throws:
FileNotFoundException- Thrown if file is not found
-
toString
Returns a string representation of this object
-