Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. public void onClick(View v) {
  2. if (v.getId()==R.id.loadDataId){
  3.  
  4. SharedPreferences sharedPreferences = getSharedPreferences("Mydata",MODE_PRIVATE);
  5. String name = sharedPreferences.getString("uname",DEFAULTVALUE);
  6. String pass = sharedPreferences.getString("pass",DEFAULTVALUE);
  7.  
  8. if (name.equals(DEFAULTVALUE)|| pass.equals(DEFAULTVALUE)){
  9.  
  10. Toast.makeText(this, "No Data was found", Toast.LENGTH_SHORT).show();
  11. }else {
  12.  
  13. unamrTextView.setText(name);
  14. passTextView.setText(pass);
  15.  
  16. Toast.makeText(this, "Data retrive successfully", Toast.LENGTH_SHORT).show();
  17. }
  18.  
  19. }else if (v.getId()==R.id.backId){
  20. Intent intent = new Intent(this,MainActivity.class);
  21. startActivity(intent);
  22. Toast.makeText(this, "Go to Main Activity", Toast.LENGTH_SHORT).show();
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement