Guest User

Untitled

a guest
Jun 22nd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public void save(){
  2. String arquivo;//Log.i("VALOR", campos);
  3. String dados = "teste@teste.com" + "," + "123456";
  4. try {
  5. FileOutputStream fos = openFileOutput(arquivo, Context.MODE_PRIVATE);
  6. fos.write(dados.getBytes());
  7. fos.close();
  8. Log.i("VALOR", arquivo);
  9. } catch (Exception e) {
  10. E.printStackTrace();
  11. }
  12. }
  13.  
  14. public void ler() {
  15. String email = "";
  16. String senha = "";
  17. String temp = "";
  18. try {
  19. FileInputStream fin = openFileInput(arquivo);
  20.  
  21. int c;
  22. int ok = 0;
  23.  
  24. while ((c = fin.read()) != -1) {
  25. if (!(Character.toString((char) c).equals(",")) && ok != 1) {
  26. email = email + Character.toString((char) c);
  27. } else if (ok == 0) {
  28. ok = 1;
  29. }
  30. if (!(Character.toString((char) c).equals(",")) && ok == 1) {
  31. senha = senha + Character.toString((char) c);
  32. }
  33. temp = temp + Character.toString((char) c);
  34. }
  35.  
  36. Log.i("VALORES", "Valor Email: " + email);
  37. Log.i("VALORES", "Valor Senha: " + senha);
  38. Log.i("VALORES", "Valor Temp: " + temp);
  39.  
  40. } catch (Exception e) {
  41.  
  42. }
  43. }
Add Comment
Please, Sign In to add comment