Methods Summary |
---|
public boolean | canRead()
return mFile.canRead();
|
public boolean | canWrite()
return mFile.canWrite();
|
public DocumentFile | createDirectory(java.lang.String displayName)
final File target = new File(mFile, displayName);
if (target.isDirectory() || target.mkdir()) {
return new RawDocumentFile(this, target);
} else {
return null;
}
|
public DocumentFile | createFile(java.lang.String mimeType, java.lang.String displayName)
// Tack on extension when valid MIME type provided
final String extension = MimeTypeMap.getSingleton().getExtensionFromMimeType(mimeType);
if (extension != null) {
displayName += "." + extension;
}
final File target = new File(mFile, displayName);
try {
target.createNewFile();
return new RawDocumentFile(this, target);
} catch (IOException e) {
Log.w(TAG, "Failed to createFile: " + e);
return null;
}
|
public boolean | delete()
deleteContents(mFile);
return mFile.delete();
|
private static boolean | deleteContents(java.io.File dir)
File[] files = dir.listFiles();
boolean success = true;
if (files != null) {
for (File file : files) {
if (file.isDirectory()) {
success &= deleteContents(file);
}
if (!file.delete()) {
Log.w(TAG, "Failed to delete " + file);
success = false;
}
}
}
return success;
|
public boolean | exists()
return mFile.exists();
|
public java.lang.String | getName()
return mFile.getName();
|
public java.lang.String | getType()
if (mFile.isDirectory()) {
return null;
} else {
return getTypeForName(mFile.getName());
}
|
private static java.lang.String | getTypeForName(java.lang.String name)
final int lastDot = name.lastIndexOf('.");
if (lastDot >= 0) {
final String extension = name.substring(lastDot + 1).toLowerCase();
final String mime = MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
if (mime != null) {
return mime;
}
}
return "application/octet-stream";
|
public android.net.Uri | getUri()
return Uri.fromFile(mFile);
|
public boolean | isDirectory()
return mFile.isDirectory();
|
public boolean | isFile()
return mFile.isFile();
|
public long | lastModified()
return mFile.lastModified();
|
public long | length()
return mFile.length();
|
public DocumentFile[] | listFiles()
final ArrayList<DocumentFile> results = new ArrayList<DocumentFile>();
final File[] files = mFile.listFiles();
if (files != null) {
for (File file : files) {
results.add(new RawDocumentFile(this, file));
}
}
return results.toArray(new DocumentFile[results.size()]);
|
public boolean | renameTo(java.lang.String displayName)
final File target = new File(mFile.getParentFile(), displayName);
if (mFile.renameTo(target)) {
mFile = target;
return true;
} else {
return false;
}
|