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
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;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With