Advertisement
Guest User

Android Problem

a guest
Mar 26th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. To load:
  2.  
  3. @SuppressWarnings("rawtypes")
  4. public static void saveHM(HashMap hm, String s) {
  5. try {
  6. File file = new File("data/data/at.enagon.micromon.main", s);
  7. FileOutputStream fos = new FileOutputStream(file);
  8. ObjectOutputStream oos = new ObjectOutputStream(fos);
  9. oos.writeObject(hm);
  10. oos.flush();
  11. oos.close();
  12. fos.close();
  13. } catch (FileNotFoundException e) {
  14. e.printStackTrace();
  15. } catch (IOException e) {
  16. e.printStackTrace();
  17. }
  18. }
  19.  
  20. To save:
  21.  
  22. @SuppressWarnings("rawtypes")
  23. public static HashMap loadHM(String s) {
  24. try {
  25. File file = new File("data/data/at.enagon.micromon.main", s);
  26. FileInputStream fis = new FileInputStream(file);
  27. ObjectInputStream ois = new ObjectInputStream(fis);
  28. Object o = ois.readObject();
  29. HashMap hm = (HashMap) o;
  30. ois.close();
  31. fis.close();
  32. return hm;
  33. } catch (IOException e) {
  34. e.printStackTrace();
  35. } catch (ClassNotFoundException e) {
  36. e.printStackTrace();
  37. }
  38. return null;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement