Hi i\'m streaming video from a website in my android application. I have a history option showing the last seen videos. I wonder if i can use cache so that when the user ent
It should help you.
URLConnection cn = new URL(mediaUrl).openConnection();
cn.connect();
InputStream stream = cn.getInputStream();
File downloadingMediaFile = new File(context.getCacheDir(), "downloadingMedia.dat");
FileOutputStream out = new FileOutputStream(downloadingMediaFile);
byte buf[] = new byte[16384];
do {
int numread = stream.read(buf);
if (numread <= 0) break;
out.write(buf, 0, numread);
// ...
} while (...);