4

I have created a directory in android internal storage using following lines:

File directory = getDir("template", Context.MODE_PRIVATE);

I need to add some files in this 'template' directory from sdcard, what is the way to achieve this?

Any help is appreciated..

Thanks

Neo
  • 5,070
  • 10
  • 46
  • 65

1 Answers1

8

try using this method. in that you should give source and destination file names.

private boolean copyFile(File src,File dst)throws IOException{
        if(src.getAbsolutePath().toString().equals(dst.getAbsolutePath().toString())){

            return true;

        }else{
            InputStream is=new FileInputStream(src);
            OutputStream os=new FileOutputStream(dst);
            byte[] buff=new byte[1024];
            int len;
            while((len=is.read(buff))>0){
                os.write(buff,0,len);
            }
            is.close();
            os.close();
        }
        return true;
    }
ilango j
  • 5,967
  • 2
  • 28
  • 25
  • 2
    http://stackoverflow.com/questions/4770004/how-to-move-rename-file-from-internal-app-storage-to-external-storage-on-android was also helpful – Neo Aug 12 '11 at 09:47