title: Android: How to check does shared preferences exist, and how to delete them
body: <p>To check does preferences exist I tried this way, but it shows null every time(maybe because I saved preferences in different view):</p>
  
  <pre><code>String def = null; 
  String test = getPreferences(MODE_PRIVATE).getString(PREF_GAME,def);
  if(test == null) Log.v("main", "no saved data");
  </code></pre>
  
  <p>To delete preferences I tried editor.clear(), but it does't delete (however commit() every time return true):</p>
  
  <pre><code>   SharedPreferences preferences = getSharedPreferences(PREF_GAME,MODE_PRIVATE);
     SharedPreferences.Editor editor = preferences.edit();
     editor.clear();
     boolean tt = editor.commit();Log.v("DELETE PREF", String.valueOf(tt));
  </code></pre>
  
  <p><strong>UPDATE:</strong> I found that if I check preferences exist in the same view, where i saved it, this checking works fine, but how can i do this in different view?</p>
  
  <p><strong>Update:</strong> I guessed with myself, thanks everyone!</p>