Read font size from Settings

This question is a almost dublicate of Android App: how to read Font Size under Settings? I read the answer of CommonsWare which points to use Settings.System.FONT_SCALE. So I wrote this few lines:

float scale = -66.6f;
try {
    scale = android.provider.Settings.System.getFloat(getContentResolver(),
} catch(SettingNotFoundException e) {
    Log.e(getClass().getSimpleName(), "Error: ", e);
Toast.makeText(this, "scale=" + scale, Toast.LENGTH_LONG).show();

My problem is that I always get the SettingNotFoundException I’m using an Android 4.2.2 device. By the way I that code is in an onCreate callback of an Activity.

  • How to capture the onSwipeDown event on google glass using a native app?
  • When does android show a pairing dialog when using insecure RFCOMM bluetooth sockets?
  • The method getApplicationContext() is undefined - fragment issues
  • “Unable to open log device '/dev/log/main': No such file or directory”
  • Get GPS location via a service in Android
  • Upgraded to AppCompat v22.1.0 and now onKeyDown and onKeyUp are not triggered when menu key is pressed
  • I also googled for that problem and found about 3 sites which uses the same code. Is some special permission required? I tried also the permission android.permission.WRITE_SETTINGS without success.

    Related posts:

    Write android logcat data to a file
    Activating Network Location Provider in the Android Emulator?
    Android Unit Test with Retrofit and Mockito
    Android SDK Manager won't update: connection to refused
    Android How to change the application title
    Fetch dial number while calling.
  • How to serialize a Bundle?
  • PACKAGE_REMOVED & then PACKAGE_ADDED are fired along with PACKAGE_REPLACED Intent Action
  • Knowing when a View in a ListView has gone off the screen?
  • Google Analytics in Android app - dealing with multiple activities
  • Android webview using GSAP: Attempt to remove non-JNI local reference, dumping thread
  • Calling Activity Method From Inside A Fragment
  • 4 Solutions collect form web for “Read font size from Settings”

    I just found in the source code of Settings.System this function:

    /** @hide */
    public static void getConfigurationForUser(ContentResolver cr,
                                           Configuration outConfig, int userHandle) {
        outConfig.fontScale = Settings.System.getFloatForUser(
            cr, FONT_SCALE, outConfig.fontScale, userHandle);
        if (outConfig.fontScale < 0) {
            outConfig.fontScale = 1;

    There is however the FONT_SCALE in usage so I checked for that Configuration class where the documentation points to getResources().getConfiguration(). So I cound fix my code by using:

    float scale = getResources().getConfiguration().fontScale;

    You can set system font according to font scale.

    Example: For huge font scale is 2.0 then you can set as follow.

    Configuration config = new Configuration();
    config.fontScale = 2.0f;

    You could probably use getResources().getDisplayMetrics().scaledDensity

    Add “float def” param to the end of the
    public static float getFloat(ContentResolver cr, String name, float def)


    scale = android.provider.Settings.System.getFloat(getActivity().getContentResolver(),
    android.provider.Settings.System.FONT_SCALE, 1f);

    Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.