Guest User

Untitled

a guest
Jan 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. Properties props = new Properties();
  2. InputStream inputStream = null;
  3. try{
  4. inputStream = getBaseContext().getAssets().open("userInfo.properties");
  5. props.load(inputStream);
  6.  
  7. props.put("name", "smith");
  8. FileOutputStream output = new FileOutputStream("userInfo.properties"); //this line throws error
  9. props.store(output, "This is overwrite file");
  10.  
  11. String name = props.getProperty("name");
  12. Log.d(TAG, "onCreate: PROPERTIES TEST NAME CHANGE: " + name);
  13.  
  14. } catch (IOException e) {
  15. e.printStackTrace();
  16. } finally {
  17. try {
  18. inputStream.close();
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22. }
Add Comment
Please, Sign In to add comment