本文整理汇总了Java中android.os.ParcelFileDescriptor.MODE_APPEND属性的典型用法代码示例。如果您正苦于以下问题:Java ParcelFileDescriptor.MODE_APPEND属性的具体用法?Java ParcelFileDescriptor.MODE_APPEND怎么用?Java ParcelFileDescriptor.MODE_APPEND使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.os.ParcelFileDescriptor
的用法示例。
在下文中一共展示了ParcelFileDescriptor.MODE_APPEND属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parseMode
public static int parseMode(String mode) {
final int modeBits;
if ("r".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
} else if ("w".equals(mode) || "wt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else if ("wa".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_APPEND;
} else if ("rw".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE;
} else if ("rwt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else {
throw new IllegalArgumentException("Bad mode '" + mode + "'");
}
return modeBits;
}
示例2: modeToMode
/**
* Copied from ContentResolver.java
*/
private static int modeToMode(String mode) {
int modeBits;
if ("r".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
} else if ("w".equals(mode) || "wt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else if ("wa".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_APPEND;
} else if ("rw".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE;
} else if ("rwt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else {
throw new IllegalArgumentException("Invalid mode: " + mode);
}
return modeBits;
}
示例3: modeToMode
static public int modeToMode(Uri uri, String mode) throws FileNotFoundException {
int modeBits;
if ("r".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_ONLY;
} else if ("w".equals(mode) || "wt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else if ("wa".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_WRITE_ONLY
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_APPEND;
} else if ("rw".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE;
} else if ("rwt".equals(mode)) {
modeBits = ParcelFileDescriptor.MODE_READ_WRITE
| ParcelFileDescriptor.MODE_CREATE
| ParcelFileDescriptor.MODE_TRUNCATE;
} else {
throw new FileNotFoundException("Bad mode for " + uri + ": "
+ mode);
}
return modeBits;
}
示例4: openFile
/**
* Remotely opens a file
*/
@Override
public ParcelFileDescriptor openFile(final Uri uri, String mode) throws FileNotFoundException {
if (Constants.LOGVV) {
logVerboseOpenFileInfo(uri, mode);
}
final Cursor cursor = queryCleared(uri, new String[]{
Downloads.Impl._DATA, Downloads.Impl.COLUMN_STATUS,
Downloads.Impl.COLUMN_DESTINATION, Downloads.Impl.COLUMN_MEDIA_SCANNED}, null,
null, null);
final String path;
final boolean shouldScan;
try {
int count = (cursor != null) ? cursor.getCount() : 0;
if (count != 1) {
// If there is not exactly one result, throw an appropriate exception.
if (count == 0) {
throw new FileNotFoundException("No entry for " + uri);
}
throw new FileNotFoundException("Multiple items at " + uri);
}
if (cursor.moveToFirst()) {
final int status = cursor.getInt(1);
final int destination = cursor.getInt(2);
final int mediaScanned = cursor.getInt(3);
path = cursor.getString(0);
shouldScan = Downloads.Impl.isStatusSuccess(status) && (
destination == Downloads.Impl.DESTINATION_EXTERNAL
|| destination == Downloads.Impl.DESTINATION_FILE_URI
|| destination == Downloads.Impl.DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD)
&& mediaScanned != 2;
} else {
throw new FileNotFoundException("Failed moveToFirst");
}
} finally {
IoUtils.closeQuietly(cursor);
}
if (path == null) {
throw new FileNotFoundException("No filename found.");
}
final File file = new File(path);
int fileMode = 0;
if (mode.contains("w")) {
fileMode |= ParcelFileDescriptor.MODE_WRITE_ONLY;
}
if (mode.contains("r")) {
fileMode |= ParcelFileDescriptor.MODE_READ_ONLY;
}
if (mode.contains("+")) {
fileMode |= ParcelFileDescriptor.MODE_APPEND;
}
return ParcelFileDescriptor.open(file, fileMode);
}
示例5: openFile
/**
* Remotely opens a file
*/
@Override
public ParcelFileDescriptor openFile(final Uri uri, String mode) throws FileNotFoundException {
if (Constants.LOGVV) {
logVerboseOpenFileInfo(uri, mode);
}
final Cursor cursor = queryCleared(uri, new String[] {
Downloads.Impl._DATA, Downloads.Impl.COLUMN_STATUS,
Downloads.Impl.COLUMN_DESTINATION, Downloads.Impl.COLUMN_MEDIA_SCANNED }, null,
null, null);
final String path;
final boolean shouldScan;
try {
int count = (cursor != null) ? cursor.getCount() : 0;
if (count != 1) {
// If there is not exactly one result, throw an appropriate exception.
if (count == 0) {
throw new FileNotFoundException("No entry for " + uri);
}
throw new FileNotFoundException("Multiple items at " + uri);
}
if (cursor.moveToFirst()) {
final int status = cursor.getInt(1);
final int destination = cursor.getInt(2);
final int mediaScanned = cursor.getInt(3);
path = cursor.getString(0);
shouldScan = Downloads.Impl.isStatusSuccess(status) && (
destination == Downloads.Impl.DESTINATION_EXTERNAL
|| destination == Downloads.Impl.DESTINATION_FILE_URI
|| destination == Downloads.Impl.DESTINATION_NON_DOWNLOADMANAGER_DOWNLOAD)
&& mediaScanned != 2;
} else {
throw new FileNotFoundException("Failed moveToFirst");
}
} finally {
IoUtils.closeQuietly(cursor);
}
if (path == null) {
throw new FileNotFoundException("No filename found.");
}
final File file = new File(path);
int fileMode = 0;
if (mode.contains("w")) {
fileMode |= ParcelFileDescriptor.MODE_WRITE_ONLY;
}
if (mode.contains("r")) {
fileMode |= ParcelFileDescriptor.MODE_READ_ONLY;
}
if (mode.contains("+")) {
fileMode |= ParcelFileDescriptor.MODE_APPEND;
}
return ParcelFileDescriptor.open(file, fileMode);
}