public class FileCtrl
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BUNDLE_DATA |
static java.lang.String |
BUNDLE_ERROR_CODE |
static java.lang.String |
BUNDLE_ERROR_MSG |
static java.lang.String |
BUNDLE_FILE_STREAM_ID |
static java.lang.String |
BUNDLE_PARCEL_FILE_DESCRIPTOR |
static int |
RESULT_CODE_ERROR |
static int |
RESULT_CODE_SUCCESS |
| Modifier and Type | Method and Description |
|---|---|
android.os.Bundle |
canRead(java.lang.String path)
Tests whether the application can read the file denoted by this abstract pathname
not support canRead for path start with /Android/data or /Android/obb |
android.os.Bundle |
canWrite(java.lang.String path)
Tests whether the application can modify the file denoted by this abstract pathname.
|
android.os.Bundle |
closeFileStream(long fileStreamId)
Close the specific file stream that created by FileCtrl.createFileStream.
|
android.os.Bundle |
copyFile(java.lang.String fromPath,
java.lang.String toPath)
Copy file bundle.
|
android.os.Bundle |
createFile(java.lang.String path)
Create file or folder on device
|
android.os.Bundle |
createFileStream(java.lang.String filepath,
boolean keepContents)
Create a stream that you can use the stream to read or write data into the file.
|
android.os.Bundle |
deleteFile(java.lang.String path)
Deletes the file or folder.
|
android.os.Bundle |
exists(java.lang.String path)
Check if the file or folder exists.
|
android.os.Bundle |
getExternalStorageInfo()
get device external storage information include real path and description
|
static FileCtrl |
getInstance(android.content.Context context)
Gets instance.
|
android.os.Bundle |
isDirectory(java.lang.String path)
Check if path is directory.
|
android.os.Bundle |
list(java.lang.String path)
Returns an array of strings naming the files and directories in the
directory denoted by this abstract pathname.
|
android.os.Bundle |
openFile(java.lang.String path)
open file for the given package name and path
not support openFile for path start with /Android/data or /Android/obb |
android.os.Bundle |
pathConverter(java.lang.String path)
get real storage path description
|
android.os.Bundle |
readFromFile(java.lang.String path)
Read from file.
|
android.os.Bundle |
renameTo(java.lang.String path,
java.lang.String newName)
Renames the file denoted by this name.
|
android.os.Bundle |
writeToFile(java.lang.String path,
byte[] content)
Write to file with byte[]
|
android.os.Bundle |
writeUTF8ToFile(java.lang.String path,
java.lang.String content)
Write String(utf8) to file.
|
public static final java.lang.String BUNDLE_ERROR_CODE
public static final java.lang.String BUNDLE_ERROR_MSG
public static final java.lang.String BUNDLE_DATA
public static final java.lang.String BUNDLE_PARCEL_FILE_DESCRIPTOR
public static final java.lang.String BUNDLE_FILE_STREAM_ID
public static final int RESULT_CODE_ERROR
public static final int RESULT_CODE_SUCCESS
public static FileCtrl getInstance(android.content.Context context)
context - the contextpublic android.os.Bundle writeUTF8ToFile(java.lang.String path,
java.lang.String content)
path - the path (String)content - the content (String)public android.os.Bundle writeToFile(java.lang.String path,
byte[] content)
path - the path (String)content - the content (String)public android.os.Bundle readFromFile(java.lang.String path)
path - the path (String)public android.os.Bundle copyFile(java.lang.String fromPath,
java.lang.String toPath)
fromPath - the from path (String)toPath - the to path (String)public android.os.Bundle createFile(java.lang.String path)
path - The path of file or folder. If you want to create folder, the path should end with "/" like "/sdcard/newfolder/" (String)public android.os.Bundle deleteFile(java.lang.String path)
path - The path of file or folder. (String)public android.os.Bundle createFileStream(java.lang.String filepath,
boolean keepContents)
filepath - The file path that you want to make a stream on it. (String)keepContents - Whether you want to keep the file contents. If you want to read data from the stream, you should set keepContents as true. (true: keep, false: erase file) (boolean)public android.os.Bundle closeFileStream(long fileStreamId)
fileStreamId - The file stream ID that you want to close. (long)public android.os.Bundle exists(java.lang.String path)
path - The path of the file or folder. (String)public android.os.Bundle isDirectory(java.lang.String path)
path - The path of the file or folder. (String)public android.os.Bundle openFile(java.lang.String path)
path - The path of the file. (String) public android.os.Bundle list(java.lang.String path)
path - The path of the file or folder. (String)public android.os.Bundle renameTo(java.lang.String path,
java.lang.String newName)
path - The path of the file or folder. (String)public android.os.Bundle canWrite(java.lang.String path)
path - The path of the file or folder. (String)public android.os.Bundle canRead(java.lang.String path)
path - The path of the file or folder. (String)public android.os.Bundle getExternalStorageInfo()
public android.os.Bundle pathConverter(java.lang.String path)
path - The path of the file or folder that start with USB/, SD/ or FLASH/ (String)