title: Settings.System API behaviour in Android API level 23
body: <p>In my application with targetSdkVersion as 23, while using the API <em>Settings.System.putString()</em>.</p>
  
  <p>Following error is being thrown and app crashes<br>
  "AndroidRuntime: java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings."</p>
  
  <p>After trying solution at<br>
  <a href="https://stackoverflow.com/questions/32083410/android-m-6-0-ringtonemanager-manifest-permission-write-settings-error/32083622#32083622">Can&#39;t get WRITE_SETTINGS permission</a><br>
  and granting the app write permission in screen opened by ACTION_MANAGE_WRITE_SETTINGS. The app still gets the error "You cannot keep your settings in the secure settings". </p>
  
  <p>Is  requesting the WRITE_SETTINGS permission now only for apps developed by OEMs ?
  Is there a solution possible ?</p>
  
  <p>Sharing a sample code , tested on Nexus 5 device with M OS.</p>
  
  <h2>Android Manifest Snippet :</h2>
  
  <pre><code>    android:minSdkVersion="17"  
      android:targetSdkVersion="23"  
      uses-permission android:name="android.permission.WRITE_SETTINGS"
  </code></pre>
  
  <h2>Code Snippet :</h2>
  
  <pre><code>protected void onResume() {
      super.onResume();
      boolean canDo =  Settings.System.canWrite(this);
      if (false == canDo)
      {
          Intent grantIntent = new   Intent(Settings.ACTION_MANAGE_WRITE_SETTINGS);
          startActivity(grantIntent);
      }
      else
      {   
          Settings.System.putString(this.getContentResolver(),
              "test.hemant", "hemantval");
      }           
  
  }
  </code></pre>
  
  <h2>Log Stack :</h2>
  
  <pre><code>E/DatabaseUtils(  779): Writing exception to parcel
  E/DatabaseUtils(  779): java.lang.IllegalArgumentException: You cannot keep your settings in the secure settings.
  E/DatabaseUtils(  779):     at com.android.providers.settings.SettingsProvider.warnOrThrowForUndesiredSecureSettingsMutationForTargetSdk(SettingsProvider.java:1175)
  E/DatabaseUtils(  779):     at com.android.providers.settings.SettingsProvider.enforceRestrictedSystemSettingsMutationForCallingPackage(SettingsProvider.java:1030)
  E/DatabaseUtils(  779):     at com.android.providers.settings.SettingsProvider.mutateSystemSetting(SettingsProvider.java:906)
  E/DatabaseUtils(  779):     at com.android.providers.settings.SettingsProvider.insertSystemSetting(SettingsProvider.java:874)
  E/DatabaseUtils(  779):     at com.android.providers.settings.SettingsProvider.call(SettingsProvider.java:257)
  E/DatabaseUtils(  779):     at android.content.ContentProvider$Transport.call(ContentProvider.java:398)
  E/DatabaseUtils(  779):     at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:283)
  E/DatabaseUtils(  779):     at android.os.Binder.execTransact(Binder.java:453)
  D/AndroidRuntime(19935): Shutting down VM
  </code></pre>