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 IFile
copy(IFile newDir)
Copy this file to another directory.IFile
copy(IFile newDir, IFile.CopyOptions options)
Copy this file to another directory with a new filename with a progress.IFile
createDirectory(java.lang.String dirName)
Create a directory under this directory.IFile
createFile(java.lang.String filename)
Create an empty file under this directory.boolean
delete()
Delete this file.boolean
exists()
Check if file exists.IFile
getChild(java.lang.String filename)
Get a child file or directory under this directory.int
getChildrenCount()
Get the count of files and subdirectoriesjava.lang.String
getDisplayPath()
Get the display path on the physical drive.ParcelFileDescriptor
getFileDescriptor(java.lang.String mode)
Get a file descriptor corresponding to this file.RandomAccessStream
getInputStream()
Get a stream for reading.long
getLastDateModified()
Get the last modified date in milliseconds.long
getLength()
Get the size of the file.java.lang.String
getName()
Get the base name of this file.RandomAccessStream
getOutputStream()
Get a stream for writing.IFile
getParent()
Get the parent directory.java.lang.String
getPath()
Get the path on the physical disk.boolean
isDirectory()
Check if this is a directory.boolean
isFile()
Check if this is a file.IFile[]
listFiles()
List files and directories.boolean
mkdir()
Create this directory.IFile
move(IFile newDir)
Move this file to another directory.IFile
move(IFile newDir, IFile.MoveOptions options)
Move this file to another directory.boolean
renameTo(java.lang.String newFilename)
Rename this file.void
reset()
Clear cache properties.java.lang.String
toString()
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:
createDirectory
in 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:
createFile
in 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:
getDisplayPath
in 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:
getInputStream
in 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:
getOutputStream
in 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:
isDirectory
in 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:
getLastDateModified
in 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:
getChildrenCount
in 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.FileNotFoundException
Rename this file.
-
mkdir
public boolean mkdir()
Create this directory.
-
getFileDescriptor
public ParcelFileDescriptor getFileDescriptor(java.lang.String mode) throws java.io.FileNotFoundException
Get 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:
toString
in classjava.lang.Object
-
-