Example usage for android.os ParcelFileDescriptor MODE_APPEND

List of usage examples for android.os ParcelFileDescriptor MODE_APPEND

Introduction

In this page you can find the example usage for android.os ParcelFileDescriptor MODE_APPEND.

Prototype

int MODE_APPEND

To view the source code for android.os ParcelFileDescriptor MODE_APPEND.

Click Source Link

Document

For use with #open : append to end of file while writing.

Usage

From source file:com.hippo.content.FileProvider.java

/**
 * Copied from ContentResolver.java//w w w  . ja  va2 s. c om
 */
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;
}