diff --git a/android/plugins/sharedpreferences/SharedPreferencesSonarPlugin.java b/android/plugins/sharedpreferences/SharedPreferencesSonarPlugin.java index fef931a48..0e987c7e1 100644 --- a/android/plugins/sharedpreferences/SharedPreferencesSonarPlugin.java +++ b/android/plugins/sharedpreferences/SharedPreferencesSonarPlugin.java @@ -24,8 +24,36 @@ public class SharedPreferencesSonarPlugin implements SonarPlugin { private SonarConnection mConnection; private final SharedPreferences mSharedPreferences; + /** + * Creates a {@link android.content.SharedPreferences} plugin for Sonar + * + * @param context The context to retrieve the file from. Will use the package name as the file + * name with {@link Context#MODE_PRIVATE}. + */ public SharedPreferencesSonarPlugin(Context context) { - mSharedPreferences = context.getSharedPreferences(context.getPackageName(), MODE_PRIVATE); + this(context, context.getPackageName()); + } + + /** + * Creates a {@link android.content.SharedPreferences} plugin for Sonar + * + * @param context The context to retrieve the file from. Will use the name as the file name with + * {@link Context#MODE_PRIVATE}. + * @param name The preference file name. + */ + public SharedPreferencesSonarPlugin(Context context, String name) { + this(context, name, MODE_PRIVATE); + } + + /** + * Creates a {@link android.content.SharedPreferences} plugin for Sonar + * + * @param context The context to retrieve the file from. + * @param name The preference file name. + * @param mode The Context mode to utilize. + */ + public SharedPreferencesSonarPlugin(Context context, String name, int mode) { + mSharedPreferences = context.getSharedPreferences(name, mode); mSharedPreferences.registerOnSharedPreferenceChangeListener( new SharedPreferences.OnSharedPreferenceChangeListener() {