Advertisement
Guest User

Untitled

a guest
Apr 18th, 2014
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. File Db = new File("/data/data/your.package/databases/yourdatabasename");
  2. Date d = new Date();
  3.  
  4. File file = new File("your_destination.db");
  5. file.setWritable(true);
  6.  
  7. copyFile(new FileInputStream(Db), new FileOutputStream(file));
  8.  
  9. public static void copyFile(FileInputStream fromFile, FileOutputStream toFile) throws IOException {
  10. FileChannel fromChannel = null;
  11. FileChannel toChannel = null;
  12. try {
  13. fromChannel = fromFile.getChannel();
  14. toChannel = toFile.getChannel();
  15. fromChannel.transferTo(0, fromChannel.size(), toChannel);
  16. } finally {
  17. try {
  18. if (fromChannel != null) {
  19. fromChannel.close();
  20. }
  21. } finally {
  22. if (toChannel != null) {
  23. toChannel.close();
  24. }
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement