<pre name= "code" class= "HTML" >package com.lapel.activity.html;import Java.io.file;import Java.io.fileoutputstream;import Java.io.ioexception;import Java.io.inputstream;import android.content.Context;/** * * Copy the files under the Assets folder to the SD card * */public class Copyzipfiletosd {private context context; String FileName; String filepath;/** * * @param context * @param filename * FILENAME (compressed file under Assets folder): file name + suffix * @param filePath * SD Local Path */public COPYZIPFILETOSD (context context, string fileName, String filePath) {This.context = context;th Is.filename = Filename;this.filepath = FilePath;} public void Copy () {InputStream inputstream;try {inputstream = Context.getresources (). Getassets (). open (FileName);// Files file = new (FilePath) under Assets folder, if (!file.exists ()) {file.mkdirs ();} FileOutputStream FileOutputStream = new FileOutputStream (FilePath + "/" + fileName);//file saved to local folder byte[] buffer = new by Te[1024];int count = 0;while ((count = inputstream.read (buffer)) > 0) {fileOutputstream.write (buffer, 0, count);} Fileoutputstream.flush (); Fileoutputstream.close (); Inputstream.close ();} catch (IOException e) {e.printstacktrace ();}}}
Copy files from the Android Project Assets folder to the SD card