System, Settings, Change, WRITE_SETTTINGS

Quickly share your Android Code Snippets here...

System, Settings, Change, WRITE_SETTTINGS

Postby plusminus » Tue Nov 11, 2008 6:24 am

AndroidManifest.xml:
Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1. <uses-permission android:name="android.permission.WRITE_SETTINGS" />
Parsed in 0.000 seconds, using GeSHi 1.0.8.4

Any Activity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. android.provider.Settings.System.putInt(this.getContentResolver(), android.provider.Settings.System.SOUND_EFFECTS_ENABLED, 1);
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


SDK Version compatible: 1.0 (maybe prior versions too)
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Top

Postby sandis84 » Fri Aug 28, 2009 10:28 am

I dont get this to work in 1.5. How to do? =)
sandis84
Experienced Developer
Experienced Developer
 
Posts: 78
Joined: Fri Aug 07, 2009 3:54 pm

Postby WarrenFaith » Fri Aug 28, 2009 5:26 pm

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Settings.System.putInt(this.getContentResolver(), "mySetting", 1);
  2.  
  3. int setting = 0;
  4.  
  5. try {
  6.  
  7.     setting = Settings.System.getInt(this.getContentResolver(), "mySetting");
  8.  
  9. } catch (SettingNotFoundException e) {
  10.  
  11.     Log.e(LOG_TAG, "Setting mySetting not found");
  12.  
  13. }
  14.  
  15. Log.i(LOG_TAG, "Setting mySetting: " + setting);
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


works fine for me...
WarrenFaith
Moderator
Moderator
 
Posts: 227
Joined: Fri Mar 13, 2009 10:59 am
Location: Berlin, Germany

Top

Return to Code Snippets for Android

Who is online

Users browsing this forum: No registered users and 9 guests