title: SharedPreferences Clear/Save
body: <p>Iam trying to make a checker and I want to save a value into SharedPreferences. But i'am not sure if it works</p>
  
  <p><strong>This what I do to save the value is : *</strong></p>
  
  <pre><code>    SharedPreferences prefs = getSharedPreferences("PREFERENCE", MODE_PRIVATE);
      boolean firstrun = prefs.getBoolean("firstrun", true);
  
      db = openOrCreateDatabase("value.db", Context.MODE_PRIVATE, null); // optional CursorFactory
  
      if (firstrun) {
            SharedPreferences.Editor editor = prefs.edit();
  
            db.execSQL("CREATE TABLE startValue (ID Integer Primary Key, myValue Integer)");
  
            db.execSQL("INSERT INTO startValue (myValue) VALUES (2)"); 
  
            editor.putBoolean("firstrun", false);
            editor.apply();
  
             }
  
      // Save the state
      getSharedPreferences("PREFERENCE", MODE_PRIVATE)
          .edit()
          .putBoolean("firstrun", false)
          .commit();
  </code></pre>
  
  <p><strong>And to Clear the preferenece from another activity is :</strong></p>
  
  <pre><code>     try{
              db = openOrCreateDatabase("value.db", Context.MODE_PRIVATE, null); // optional CursorFactory
  
              db.execSQL("DROP TABLE IF EXISTS startValue");
              db.close();
  
              SharedPreferences preferences = getPreferences(0);
              SharedPreferences.Editor editor = preferences.edit();
  
              editor.remove("firstrun");
              editor.clear();
              editor.commit();
  
              this.finish();
          }    
          catch(SQLException ex)
          {
          //catch error here
          }
  </code></pre>
  
  <p><strong>Issue</strong></p>
  
  <p>But when i'am testing as I see its not clearing the preferences. Am I doing something wrong or?</p>