private void copy() { fileCopyTask.execute(); } private void copyAllFiles() { try { String[] list = getAssets().list(""); if (list.length == 0) return; for (String file : list) { copyFile(getFilesDir().getParentFile().getPath() + "/asdf/", file); } } catch (Exception e) { e.printStackTrace(); } } private void copyFile(String $path, String $filename) { String fullPath = $path + "/" + $filename; File path = new File($path); if (!path.exists()) path.mkdirs(); File destPath = new File(fullPath); if (destPath.exists()) destPath.delete(); try { InputStream is = getResources().getAssets().open($filename, AssetManager.ACCESS_BUFFER); if (is == null) return; byte[] tempdata = new byte[is.available()]; is.read(tempdata); is.close(); destPath.createNewFile(); FileOutputStream fo = new FileOutputStream(destPath); fo.write(tempdata); fo.close(); } catch (Exception e) { // e.printStackTrace(); } } private AsyncTask<Void, Void, Boolean> fileCopyTask = new AsyncTask<Void, Void, Boolean>() { @Override protected Boolean doInBackground(Void... params) { copyAllFiles(); return true; } protected void onPostExecute(Boolean result) { // onCopyFinished(result); }; };