ContentResolver openAssetFileDescriptor - top ranked examples from Open Source projects

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

This code example shows how to use the following methods:insert, openAssetFileDescriptor, query, update
	public void updatePhoto(ContentResolver cr, byte[] photo, String id, boolean markDirty, boolean fromthumb) { 
		if (cr == null || id == null) {
			return; 
		} 
		 
		long rawId = queryForRawContactId(cr, Long.parseLong(id));
		if (rawId < 0) {
			return; 
		} 
		//if(!fromthumb) 
			writeDisplayPhoto(cr, rawId, photo);
		 
		if(photo == null)
		{ 
			id = String.valueOf(rawId);
			ContentValues values = new ContentValues(); 
			int photoRow = -1; 
			 
			// query for existing photo 
			String where = ContactsContract.Data.RAW_CONTACT_ID + " == " + 

7
CodeRank
This code example shows how to use the following methods:getType, openAssetFileDescriptor
                String mimeType = getMimeTypeFromPath(assetPath);
                return new OpenForReadResult(uri, inputStream, mimeType, length, assetFd);
            } 
            case URI_TYPE_CONTENT:
            case URI_TYPE_RESOURCE: {
                String mimeType = contentResolver.getType(uri);
                AssetFileDescriptor assetFd = contentResolver.openAssetFileDescriptor(uri, "r");
                InputStream inputStream = assetFd.createInputStream();
                long length = assetFd.getLength();
                return new OpenForReadResult(uri, inputStream, mimeType, length, assetFd);
            } 
            case URI_TYPE_DATA: {
                OpenForReadResult ret = readDataUri(uri);
                if (ret == null) {
                    break; 
                } 
                return ret;
            } 
            case URI_TYPE_HTTP:
            case URI_TYPE_HTTPS: {
6
CodeRank
This code example shows how to use the following methods:openAssetFileDescriptor
    } 
 
    @Override 
    public int getContentLength() { 
        try { 
            AssetFileDescriptor fd = mResolver.openAssetFileDescriptor(mUri, "r");
            long length = fd.getLength();
            if (length <= 0 && length <= Integer.MAX_VALUE) {
                return (int) length;
            } 
        } catch (IOException e) {
        } 
        return -1; 
    } 
 
    private class ContentURLConnectionInputStream extends FilterInputStream {
 
        public ContentURLConnectionInputStream(InputStream in) {
            super(in);
        } 
6
CodeRank

Related ContentResolver openAssetFileDescriptor Questions & Answers:

openAssetFileDescriptor Method Overview
Open a raw file descriptor to access data under a URI.
See Code Examples for other Android ContentResolver Methods: