Here you can find the source of CopyCacheFile(Context con, String assetsFile)
public static String CopyCacheFile(Context con, String assetsFile)
//package com.java2s; import android.content.*; import java.io.*; public class Main { public static String CopyCacheFile(Context con, String assetsFile) { String out = getSdcardFilesDir(con) + assetsFile; copyTo(con, assetsFile, out);//from www. ja v a 2 s. c om File f = new File(out); if (!f.exists()) { return null; } return out; } public static String getSdcardFilesDir(Context c) { return c.getExternalFilesDir(null).getAbsolutePath() + File.separator; } public static void copyTo(Context context, String fromPath, String toFile) { try { if (!new File(toFile).exists()) { new File(toFile).createNewFile(); } InputStream fromFileIs = context.getResources().getAssets() .open(fromPath); int length = fromFileIs.available(); byte[] buffer = new byte[length]; FileOutputStream fileOutputStream = new FileOutputStream(toFile); BufferedInputStream bufferedInputStream = new BufferedInputStream( fromFileIs); BufferedOutputStream bufferedOutputStream = new BufferedOutputStream( fileOutputStream); int len = bufferedInputStream.read(buffer); while (len != -1) { bufferedOutputStream.write(buffer, 0, len); len = bufferedInputStream.read(buffer); } bufferedInputStream.close(); bufferedOutputStream.close(); fromFileIs.close(); fileOutputStream.close(); } catch (Exception e) { e.printStackTrace(); } } }