My Android app downloads a bunch of photos and videos from a server and I want to cache this data. I've used DiskLruCach library to cache the images and it works fine but now I want to cache the videos also.
I've tried something like this but it doesn't seem to work - I can't find anything in the cache directory for the videos:
private boolean writeVideoToFile(String videoUri, DiskLruCache.Editor editor ) throws IOException, FileNotFoundException {
OutputStream out = null;
FileOutputStream fos;
try {
out = new BufferedOutputStream( editor.newOutputStream(0), Utils.IO_BUFFER_SIZE );
File videoFile = Utils.createFile(Utils.TYPE_VIDEO_FILE);
fos = new FileOutputStream(videoFile);
fos.write(videoUri.getBytes());
fos.close();
return true;
} finally {
if ( out != null ) {
out.close();
}
}
}
Can anyone give me an ideea on how I can accomplish this?