TheNameOfRose

Untitled

Jul 4th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. @Override
  2. public boolean onCreateOptionsMenu(Menu menu) {
  3. MenuInflater menuInflater = getMenuInflater();
  4.  
  5. menuInflater.inflate(R.menu.main_menu, menu);
  6.  
  7.  
  8. return super.onCreateOptionsMenu(menu);
  9. }
  10. ////////////////////////////
  11. @Override
  12. public boolean onOptionsItemSelected(@NonNull MenuItem item) {
  13. super.onOptionsItemSelected(item);
  14. switch (item.getItemId()){
  15. case R.id.app_bar_search:
  16. System.out.println("done");
  17. return true;
  18. }
  19. return true;
  20. }
  21.  
  22.  
  23. ///////////////////
  24.  
  25.  
  26. SharedPreferences sharedPreferences = getSharedPreferences("com.example.sharedpreferences", Context.MODE_PRIVATE);
  27. ///
  28.  
  29. try {
  30. sharedPreferences.edit().putString("name", ObjectSerializer.serialize("String")).apply();
  31. } catch (IOException e) {
  32. e.printStackTrace();
  33. }
  34. ////
  35. String getString = null;
  36. try {
  37. getString = (String) ObjectSerializer.deserialize(sharedPreferences.getString("name", "null"));
  38. } catch (IOException e) {
  39. e.printStackTrace();
  40. }
Advertisement
Add Comment
Please, Sign In to add comment