Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. private String PREFS_KEY = "misdatos";
  2.  
  3. public void guardaIP(Context context, String valor) {
  4. SharedPreferences settings = context.getSharedPreferences(PREFS_KEY, MODE_PRIVATE);
  5. SharedPreferences.Editor editor;
  6. editor = settings.edit();
  7. editor.putString("myIP", valor);
  8. editor.commit();
  9. }
  10.  
  11.  
  12.  
  13. public String obtieneIP(Context context) {
  14. SharedPreferences preferences = context.getSharedPreferences(PREFS_KEY, MODE_PRIVATE);
  15. return preferences.getString("myIP", "");
  16. }
  17.  
  18. guardaIP(getApplicationContext(), EditTextIP.getText().ToString());
  19.  
  20. EditTextIP.setText(obtieneIP(getApplicationContext()));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement