What I understood about context.MODE_PRIVATE or MODE_READABLE, WRITABLE , is that these functions make files for sharedprefrences.
I am wondering what the difference is between context.getSharedPreferences(KEY, Context.MODE_PRIVATE) and getSharedPreferences(KEY, 0); .
getSharedPreferences retrieves preferences from the xml folder as far as I know. And context.MODE_PRIVATE stores its files. And why use context.getSharedPreferences(KEY, Context.MODE_PRIVATE) if the getSharedPreferences(KEY, 0) and context.getSharedPreferences(KEY, Context.MODE_PRIVATE) files create.
Below is the part of the Facebook API where I noticed context.MODE_PRIVATE .
public static boolean save(Facebook session, Context context) { Editor editor = context.getSharedPreferences(KEY, Context.MODE_PRIVATE).edit(); editor.putString(TOKEN, session.getAccessToken()); editor.putLong(EXPIRES, session.getAccessExpires()); return editor.commit(); } public static boolean restore(Facebook session, Context context) { SharedPreferences savedSession = context.getSharedPreferences(KEY, Context.MODE_PRIVATE); session.setAccessToken(savedSession.getString(TOKEN, null)); session.setAccessExpires(savedSession.getLong(EXPIRES, 0)); return session.isSessionValid(); }
source share