Skip to content

Instantly share code, notes, and snippets.

@amudi
Created February 17, 2011 10:22
Show Gist options
  • Save amudi/831451 to your computer and use it in GitHub Desktop.
Save amudi/831451 to your computer and use it in GitHub Desktop.
[Android] get SharedPreferences name from its resource id
public static String getSharedPreferenceName(Context ctx, int prefResId) {
String packageName = ctx.getApplicationContext().getPackageName();
Resources res = ctx.getResources();
String entryName = res.getResourceEntryName(prefResId);
return packageName + "_" + entryName;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment