ContentValues getAsByteArray - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for ContentValues getAsByteArray method.

This code example shows how to use the following methods:containsKey, getAsByteArray, putNull
     * If a photo was specified but could not be processed, this will return false. 
     * @param values The content values passed in. 
     * @return Whether processing was successful - on failure, the operation should abort. 
     */ 
    private boolean preProcessPhoto(ContentValues values) {
        if (values.containsKey(Photo.PHOTO)) {
            boolean photoExists = hasNonNullPhoto(values);
            if (photoExists) {
                if (!processPhoto(values)) {
                    // A photo was passed in, but we couldn't process it.  Update failed. 
                    return false; 
                } 
            } else { 
                // The photo key was passed in, but it was either null or an empty byte[]. 
                // We should set the photo and photo file ID fields to null for the update. 
                values.putNull(Photo.PHOTO);
                values.putNull(Photo.PHOTO_FILE_ID);
            } 
        } 
        return true; 

8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsByteArray, getAsInteger, getAsLong
                    nRet = 1;
                break; 
 
            case FILE_NAME:
                try { 
                    long lOffset = values.getAsLong("offset");
                    byte [] buf = values.getAsByteArray(CHUNK);
                    int    nLength = values.getAsInteger(LENGTH);
                    if ((buf != null) && (nLength > 0)) {
                        File f = new File(selection);
                        dstFile = new FileOutputStream(f, (lOffset == 0 ? false : true));
                        dstFile.write(buf,0, nLength);
                        dstFile.flush();
                        dstFile.close();
                        nRet = nLength;
                    } 
                } catch (FileNotFoundException fnfe) {
                    fnfe.printStackTrace();
                } catch (IOException ioe) {
                    try { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsByteArray, getAsInteger, getAsLong
                    nRet = 1;
                break; 
 
            case FILE_NAME:
                try { 
                    long lOffset = values.getAsLong("offset");
                    byte [] buf = values.getAsByteArray(CHUNK);
                    int    nLength = values.getAsInteger(LENGTH);
                    if ((buf != null) && (nLength > 0)) {
                        File f = new File(selection);
                        dstFile = new FileOutputStream(f, (lOffset == 0 ? false : true));
                        dstFile.write(buf,0, nLength);
                        dstFile.flush();
                        dstFile.close();
                        nRet = nLength;
                    } 
                } catch (FileNotFoundException fnfe) {
                    fnfe.printStackTrace();
                } catch (IOException ioe) {
                    try { 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, getAsByteArray
        } 
 
        public byte[] getAsByteArray(String key) {
            if (mAfter != null && mAfter.containsKey(key)) {
                return mAfter.getAsByteArray(key);
            } else if (mBefore != null && mBefore.containsKey(key)) {
                return mBefore.getAsByteArray(key);
            } else { 
                return null; 
            } 
        } 
 
        public Long getAsLong(String key) {
            if (mAfter != null && mAfter.containsKey(key)) {
                return mAfter.getAsLong(key);
            } else if (mBefore != null && mBefore.containsKey(key)) {
                return mBefore.getAsLong(key);
            } else { 
                return null; 
            } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, getAsByteArray
        } 
 
        public byte[] getAsByteArray(String key) {
            if (mAfter != null && mAfter.containsKey(key)) {
                return mAfter.getAsByteArray(key);
            } else if (mBefore != null && mBefore.containsKey(key)) {
                return mBefore.getAsByteArray(key);
            } else { 
                return null; 
            } 
        } 
 
        public Long getAsLong(String key) {
            if (mAfter != null && mAfter.containsKey(key)) {
                return mAfter.getAsLong(key);
            } else if (mBefore != null && mBefore.containsKey(key)) {
                return mBefore.getAsLong(key);
            } else { 
                return null; 
            } 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:containsKey, getAsByteArray
            return null; 
        } 
    } 
 
    public byte[] getAsByteArray(String key) {
        if (mAfter != null && mAfter.containsKey(key)) {
            return mAfter.getAsByteArray(key);
        } else if (mBefore != null && mBefore.containsKey(key)) {
            return mBefore.getAsByteArray(key);
        } else { 
            return null; 
        } 
    } 
 
    public Long getAsLong(String key) {
        if (mAfter != null && mAfter.containsKey(key)) {
            return mAfter.getAsLong(key);
        } else if (mBefore != null && mBefore.containsKey(key)) {
            return mBefore.getAsLong(key);
        } else { 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAsByteArray
    @Override public Short   getShort(String field)     { return mValues.getAsShort(field); }
    @Override public Integer getInteger(String field)   { return mValues.getAsInteger(field); }
    @Override public Long    getLong(String field)      { return mValues.getAsLong(field); }
    @Override public Float   getFloat(String field)     { return mValues.getAsFloat(field); }
    @Override public Double  getDouble(String field)    { return mValues.getAsDouble(field); }
    @Override public byte[]  getbyteArray(String field) { return mValues.getAsByteArray(field); }
 
    @Override public void set(String field, String value)  { mValues.put(field, value); }
    @Override public void set(String field, Boolean value) { mValues.put(field, value); }
    @Override public void set(String field, Byte value)    { mValues.put(field, value); }
    @Override public void set(String field, Short value)   { mValues.put(field, value); }
    @Override public void set(String field, Integer value) { mValues.put(field, value); }
    @Override public void set(String field, Long value)    { mValues.put(field, value); }
    @Override public void set(String field, Float value)   { mValues.put(field, value); }
    @Override public void set(String field, Double value)  { mValues.put(field, value); }
    @Override public void set(String field, byte[] value)  { mValues.put(field, value); }
 
    @Override public void setNull(String field) { mValues.putNull(field); }
 
    @Override public Date getDate(String field) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related ContentValues getAsByteArray Questions & Answers:

getAsByteArray Method Overview
Gets a value that is a byte array.
See Code Examples for other Android ContentValues Methods: