Package com.mku.android.fs.file
Class AndroidFile
- java.lang.Object
-
- com.mku.android.fs.file.AndroidFile
-
- All Implemented Interfaces:
IFile
public class AndroidFile extends java.lang.Object implements 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
-
Fields inherited from interface com.mku.fs.file.IFile
autoRename
-
-
Constructor Summary
Constructors Constructor Description AndroidFile(DocumentFile documentFile, Context context)Construct an AndroidFile wrapper from an Android DocumentFile.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description IFilecopy(IFile newDir)Copy this file to another directory.IFilecopy(IFile newDir, IFile.CopyOptions options)Copy this file to another directory with a new filename with a progress.IFilecreateDirectory(java.lang.String dirName)Create a directory under this directory.IFilecreateFile(java.lang.String filename)Create an empty file under this directory.booleandelete()Delete this file.booleanexists()Check if file exists.IFilegetChild(java.lang.String filename)Get a child file or directory under this directory.intgetChildrenCount()Get the count of files and subdirectoriesjava.lang.StringgetDisplayPath()Get the display path on the physical drive.ParcelFileDescriptorgetFileDescriptor(java.lang.String mode)Get a file descriptor corresponding to this file.RandomAccessStreamgetInputStream()Get a stream for reading.longgetLastDateModified()Get the last modified date in milliseconds.longgetLength()Get the size of the file.java.lang.StringgetName()Get the base name of this file.RandomAccessStreamgetOutputStream()Get a stream for writing.IFilegetParent()Get the parent directory.java.lang.StringgetPath()Get the path on the physical disk.booleanisDirectory()Check if this is a directory.booleanisFile()Check if this is a file.IFile[]listFiles()List files and directories.booleanmkdir()Create this directory.IFilemove(IFile newDir)Move this file to another directory.IFilemove(IFile newDir, IFile.MoveOptions options)Move this file to another directory.booleanrenameTo(java.lang.String newFilename)Rename this file.voidreset()Clear cache properties.java.lang.StringtoString()Returns a string representation of this object-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.mku.fs.file.IFile
copyRecursively, copyRecursively, deleteRecursively, deleteRecursively, moveRecursively, moveRecursively
-
-
-
-
Method Detail
-
createDirectory
public IFile createDirectory(java.lang.String dirName)
Create a directory under this directory.- Specified by:
createDirectoryin interfaceIFile- Parameters:
dirName- The directory name.- Returns:
- The new directory.
-
createFile
public IFile createFile(java.lang.String filename)
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
public java.lang.String getDisplayPath()
Get the display path on the physical drive.- Specified by:
getDisplayPathin interfaceIFile- Returns:
- The display path
-
getName
public java.lang.String getName()
Get the base name of this file.
-
getInputStream
public RandomAccessStream getInputStream() throws java.io.FileNotFoundException
Get a stream for reading.- Specified by:
getInputStreamin interfaceIFile- Returns:
- The input stream
- Throws:
java.io.FileNotFoundException- Thrown if file is not found
-
getOutputStream
public RandomAccessStream getOutputStream() throws java.io.FileNotFoundException
Get a stream for writing.- Specified by:
getOutputStreamin interfaceIFile- Returns:
- The output stream
- Throws:
java.io.FileNotFoundException- Thrown if file not found
-
getParent
public IFile getParent()
Get the parent directory.
-
getPath
public java.lang.String 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
public IFile[] listFiles()
List files and directories.
-
move
public IFile move(IFile newDir) throws java.io.IOException
Move this file to another directory.
-
move
public IFile move(IFile newDir, IFile.MoveOptions options) throws java.io.IOException
Move this file to another directory.
-
copy
public IFile copy(IFile newDir) throws java.io.IOException
Copy this file to another directory.
-
copy
public IFile copy(IFile newDir, IFile.CopyOptions options) throws java.io.IOException
Copy this file to another directory with a new filename with a progress.
-
getChild
public IFile getChild(java.lang.String filename)
Get a child file or directory under this directory.
-
renameTo
public boolean renameTo(java.lang.String newFilename) throws java.io.FileNotFoundExceptionRename this file.
-
mkdir
public boolean mkdir()
Create this directory.
-
getFileDescriptor
public ParcelFileDescriptor getFileDescriptor(java.lang.String mode) throws java.io.FileNotFoundExceptionGet a file descriptor corresponding to this file.- Parameters:
mode- The mode- Returns:
- The parcel file descriptor
- Throws:
java.io.FileNotFoundException- Thrown if file is not found
-
toString
public java.lang.String toString()
Returns a string representation of this object- Overrides:
toStringin classjava.lang.Object
-
-