private void copyFile(String source, String destination) {
InputStream srcStream;
FileOutputStream desStream;
try {
srcStream = this.getResources().getAssets().open(source);
desStream = new FileOutputStream(new File(destination));
byte [] data= new byte [1024];
while (srcStream.read(data) != -1) {
desStream.write(data);
}
srcStream.close();
desStream.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
add below expression in the AndroidManiFest.xml for getting access permission.
把這行加到AndroidManiFest.xml才有寫入權限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
沒有留言:
張貼留言