Advertisement
Guest User

[Android]FileBuilder.java

a guest
Mar 25th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.76 KB | None | 0 0
  1.  public boolean createUserFile(String username, String password){
  2.  
  3.         this.xmlContent = "<?xml version='1.0' encoding='UTF-8'?>\n" +
  4.                 "<giocatore>\n" +
  5.                 "<username>"+username+"</username>\n" +
  6.                 "<password>"+password+"</password>\n" +
  7.                 "</giocatore>";
  8.  
  9.         this.filename = "[D&D]User.xml";
  10.  
  11.         try{
  12.             outputStream = context.openFileOutput(filename, context.MODE_PRIVATE);
  13.             outputStream.write(xmlContent.getBytes());
  14.             outputStream.close();
  15.             System.out.println("----------------- File created -----------------");
  16.             return true;
  17.         } catch (IOException e) {
  18.             e.printStackTrace();
  19.             return false;
  20.         }
  21.  
  22.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement