android Programming Glossary: copyfile
Looking for a working example of addTimedTextSource for adding subtitle to a video from an .srt file in Android 4.1 http://stackoverflow.com/questions/13422673/looking-for-a-working-example-of-addtimedtextsource-for-adding-subtitle-to-a-vid resId outputStream new FileOutputStream subtitleFile false copyFile inputStream outputStream return subtitleFile.getAbsolutePath.. closeStreams inputStream outputStream return private void copyFile InputStream inputStream OutputStream outputStream throws IOException..
Making a database backup to SDCard on Android http://stackoverflow.com/questions/2814213/making-a-database-backup-to-sdcard-on-android exportDir dbFile.getName try file.createNewFile this.copyFile dbFile file return true catch IOException e Log.e mypck e.getMessage.. ctx Export failed Toast.LENGTH_SHORT .show void copyFile File src File dst throws IOException FileChannel inChannel new..
Android: How to create a directory on the SD Card and copy files from /res/raw to it? http://stackoverflow.com/questions/3851712/android-how-to-create-a-directory-on-the-sd-card-and-copy-files-from-res-raw-t i out new FileOutputStream basepath clipart files i copyFile in out in.close in null out.flush out.close out null catch.. ERROR e.toString e.printStackTrace private void copyFile InputStream in OutputStream out throws IOException byte buffer..
Android: How to copy files in 'assets' to sdcard? http://stackoverflow.com/questions/4447477/android-how-to-copy-files-in-assets-to-sdcard null filename out new FileOutputStream outFile copyFile in out in.close in null out.flush out.close out null catch IOException.. tag Failed to copy asset file filename e private void copyFile InputStream in OutputStream out throws IOException byte buffer..
Is it possible to run a native arm binary on a non-rooted android phone? http://stackoverflow.com/questions/4703131/is-it-possible-to-run-a-native-arm-binary-on-a-non-rooted-android-phone nativeFolder You can do this like so private static void copyFile String assetPath String localPath Context context try InputStream..
How to move/rename file from internal app storage to external storage on Android? http://stackoverflow.com/questions/4770004/how-to-move-rename-file-from-internal-app-storage-to-external-storage-on-android versa using following piece of code public static void copyFile File src File dst throws IOException FileChannel inChannel new..
Android: simple export and import of sqlite database http://stackoverflow.com/questions/6540906/android-simple-export-and-import-of-sqlite-database to import a database file. EDIT I pasted my FileUtils.copyFile method into the question. SQLiteOpenHelper public static String.. File oldDb new File DB_FILEPATH if newDb.exists FileUtils.copyFile new FileInputStream newDb new FileOutputStream oldDb Access.. for the file to copy to. public static void copyFile FileInputStream fromFile FileOutputStream toFile throws IOException..
Looking for a working example of addTimedTextSource for adding subtitle to a video from an .srt file in Android 4.1 http://stackoverflow.com/questions/13422673/looking-for-a-working-example-of-addtimedtextsource-for-adding-subtitle-to-a-vid null try inputStream getResources .openRawResource resId outputStream new FileOutputStream subtitleFile false copyFile inputStream outputStream return subtitleFile.getAbsolutePath catch Exception e e.printStackTrace finally closeStreams inputStream.. catch Exception e e.printStackTrace finally closeStreams inputStream outputStream return private void copyFile InputStream inputStream OutputStream outputStream throws IOException final int BUFFER_SIZE 1024 byte buffer new byte BUFFER_SIZE..
Making a database backup to SDCard on Android http://stackoverflow.com/questions/2814213/making-a-database-backup-to-sdcard-on-android if exportDir.exists exportDir.mkdirs File file new File exportDir dbFile.getName try file.createNewFile this.copyFile dbFile file return true catch IOException e Log.e mypck e.getMessage e return false can use UI thread here protected.. ctx Export successful Toast.LENGTH_SHORT .show else Toast.makeText ctx Export failed Toast.LENGTH_SHORT .show void copyFile File src File dst throws IOException FileChannel inChannel new FileInputStream src .getChannel FileChannel outChannel new..
Android: How to create a directory on the SD Card and copy files from /res/raw to it? http://stackoverflow.com/questions/3851712/android-how-to-create-a-directory-on-the-sd-card-and-copy-files-from-res-raw-t OutputStream out null try in assetManager.open clipart files i out new FileOutputStream basepath clipart files i copyFile in out in.close in null out.flush out.close out null catch Exception e Log.e copy clipart ERROR e.toString e.printStackTrace.. out.close out null catch Exception e Log.e copy clipart ERROR e.toString e.printStackTrace private void copyFile InputStream in OutputStream out throws IOException byte buffer new byte 1024 int read while read in.read buffer 1 out.write..
Android: How to copy files in 'assets' to sdcard? http://stackoverflow.com/questions/4447477/android-how-to-copy-files-in-assets-to-sdcard in assetManager.open filename File outFile new File getExternalFilesDir null filename out new FileOutputStream outFile copyFile in out in.close in null out.flush out.close out null catch IOException e Log.e tag Failed to copy asset file filename e.. in null out.flush out.close out null catch IOException e Log.e tag Failed to copy asset file filename e private void copyFile InputStream in OutputStream out throws IOException byte buffer new byte 1024 int read while read in.read buffer 1 out.write..
Is it possible to run a native arm binary on a non-rooted android phone? http://stackoverflow.com/questions/4703131/is-it-possible-to-run-a-native-arm-binary-on-a-non-rooted-android-phone to a runnable location like data data com.yourdomain.yourapp nativeFolder You can do this like so private static void copyFile String assetPath String localPath Context context try InputStream in context.getAssets .open assetPath FileOutputStream..
How to move/rename file from internal app storage to external storage on Android? http://stackoverflow.com/questions/4770004/how-to-move-rename-file-from-internal-app-storage-to-external-storage-on-android To copy files from internal memory to SD card and vice versa using following piece of code public static void copyFile File src File dst throws IOException FileChannel inChannel new FileInputStream src .getChannel FileChannel outChannel new..
Android: simple export and import of sqlite database http://stackoverflow.com/questions/6540906/android-simple-export-and-import-of-sqlite-database use this code in the SQLiteOpenHelper in one of my applications to import a database file. EDIT I pasted my FileUtils.copyFile method into the question. SQLiteOpenHelper public static String DB_FILEPATH data data package_name databases database.db.. to internal storage. close File newDb new File dbPath File oldDb new File DB_FILEPATH if newDb.exists FileUtils.copyFile new FileInputStream newDb new FileOutputStream oldDb Access the copied database so SQLiteHelper will cache it and mark it.. FileInputStream for the file to copy from. @param toFile FileInputStream for the file to copy to. public static void copyFile FileInputStream fromFile FileOutputStream toFile throws IOException FileChannel fromChannel null FileChannel toChannel null..
|