Created
November 13, 2019 10:59
-
-
Save AswinpAshok/7f52d9293fa2825a3e1b1fd8ff8d106e to your computer and use it in GitHub Desktop.
Revisions
-
AswinpAshok created this gist
Nov 13, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ public void copy(View view) { File source = new File("storage/emulated/0/test.apk"); File dest = new File("storage/emulated/0/test_copy.apk"); try { copyFileUsingStream(source, dest); } catch (IOException e) { e.printStackTrace(); } } private static void copyFileUsingStream(File source, File dest) throws IOException { InputStream is = null; OutputStream os = null; try { is = new FileInputStream(source); os = new FileOutputStream(dest); byte[] buffer = new byte[1024]; int length; while ((length = is.read(buffer)) > 0) { os.write(buffer, 0, length); } } finally { is.close(); os.close(); } } public void delete(View view) { File dest = new File("storage/emulated/0/test_copy.apk"); dest.delete(); } public void list(View view) { File source = new File("storage/emulated/0/"); String[] list = source.list(); for (String s : list) { Log.d("ASWIN", "list: "+s); } }