Object POBSharedPreferenceUtil

  • All Implemented Interfaces:

    
    public class POBSharedPreferenceUtil
    
                        

    The object/util class manage the shared preference for OpenWrap SDK.

    • Constructor Detail

    • Method Detail

      • init

         final static Unit init(Context context)

        Initialize the shared preference by getting the default shared preference and fetch a temp value so that shared preference loads up the file and caches it. It helps in reducing the time taken to fetch the value from shared preference going further in the same app session.

        The key doesn't matter as SharedPreference internally reads the whole file once

        Parameters:
        context - Application context
      • getStringFromSharedPreference

         final static String getStringFromSharedPreference(Context context, String key, String defaultValue)

        Returns the String value saved in app's default sharedPreference for a key else return the provided default value.

        Parameters:
        key - Key against which value is saved
        defaultValue - Default value to be return, if not found
        Returns:

        string value if present in default shared preference, else return provided defaultValue

      • getIntegerFromSharedPreference

         final static Integer getIntegerFromSharedPreference(Context context, String key)

        Returns the Integer value if saved in app's default sharedPreference for given key. It returns null, if key is not found.

        Parameters:
        key - Key against which value is saved
        Returns:

        integer value if present in default shared preference, else return provided defaultValue

      • getDefaultSharedPreference

         final static SharedPreferences getDefaultSharedPreference(Context context)

        Returns the default shared preference.

        Parameters:
        context - to get the default shared preferences.
        Returns:

        Instance of {@link SharedPreferences}