Copy files from the Android Project Assets folder to the SD card

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.