Android MemoryFile - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android MemoryFile class.

This code example shows how to use the following methods:writeBytes
            } 
            byte[] bytes = cursor.getBlob(0);
            if (bytes == null) {
                return null; 
            } 
            MemoryFile file = new MemoryFile(null, bytes.length);
            file.writeBytes(bytes, 0, 0, bytes.length);
             
         //   file.deactivate(); 
            return file;
        } finally { 
            cursor.close();
        } 
    } 
 
} 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:writeBytes, deactivate, fromMemoryFile
            case DATA_ID_BLOB:
                String sql = "SELECT _blob FROM data WHERE _id=" + url.getPathSegments().get(1);
                return getBlobColumnAsAssetFile(url, mode, sql);
            case HUGE:
                try { 
                    MemoryFile memoryFile = new MemoryFile(null, 5000000);
                    memoryFile.writeBytes(TEST_BLOB, 0, 1000000, TEST_BLOB.length);
                    memoryFile.deactivate();
                    return AssetFileDescriptor.fromMemoryFile(memoryFile);
                } catch (IOException ex) {
                    throw new FileNotFoundException("Error reading " + url + ":" + ex.toString());
                } 
            case FILE:
                File file = getContext().getFileStreamPath(DATA_FILE);
                ParcelFileDescriptor fd =
                        ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
                return new AssetFileDescriptor(fd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
            default: 
                throw new FileNotFoundException("No files supported by provider at " + url);
        } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:writeBytes, deactivate, fromMemoryFile
            case DATA_ID_BLOB:
                String sql = "SELECT _blob FROM data WHERE _id=" + url.getPathSegments().get(1);
                return getBlobColumnAsAssetFile(url, mode, sql);
            case HUGE:
                try { 
                    MemoryFile memoryFile = new MemoryFile(null, 5000000);
                    memoryFile.writeBytes(TEST_BLOB, 0, 1000000, TEST_BLOB.length);
                    memoryFile.deactivate();
                    return AssetFileDescriptor.fromMemoryFile(memoryFile);
                } catch (IOException ex) {
                    throw new FileNotFoundException("Error reading " + url + ":" + ex.toString());
                } 
            case FILE:
                File file = getContext().getFileStreamPath(DATA_FILE);
                ParcelFileDescriptor fd =
                        ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
                return new AssetFileDescriptor(fd, 0, AssetFileDescriptor.UNKNOWN_LENGTH);
            default: 
                throw new FileNotFoundException("No files supported by provider at " + url);
        } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:writeBytes
            } 
            byte[] bytes = cursor.getBlob(0);
            if (bytes == null) {
                return null; 
            } 
            MemoryFile file = new MemoryFile(null, bytes.length);
            file.writeBytes(bytes, 0, 0, bytes.length);
            // XXX 
            //file.deactivate(); 
            return file;
        } finally { 
            cursor.close();
        } 
    } 
 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:readBytes
    		 
    			MemoryFile mf = getMemoryFile();
    			if(mf != null) {
				try { 
    					byte[] buffer = new byte[4];
    					mf.readBytes(buffer, 0, 0, 4);
    			 
    					val = (buffer[0] << 24) | ((buffer[1] & 0xFF) << 16) | ((buffer[2] & 0xFF) << 8) | (buffer[3] & 0xFF);
				} catch(IOException ex) {
					Log.i(LOG_TAG, "Failed to read bytes from memory file.");
					ex.printStackTrace();
				} 
    			}	 
    		 
    			String text = String.valueOf(val);
    			valueText.setText(text);
    		} else if(v.equals(writeButton)) {
    			String text = valueText.getText().toString();
    			int val = Integer.parseInt(text);
    		 

4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android MemoryFile Questions & Answers:

See Code Examples for Android MemoryFile Methods: