TwitterContext extends ContextWrapper { @Override public SharedPreferences getSharedPreferences(String name, int mode) { return super.getSharedPreferences(componentName + ":" + name, mode); } TwitterContext(Context base, String componentName, String componentPath); @Override File getDatabasePath(String name); @Override SQLiteDatabase openOrCreateDatabase(String name, int mode,
            SQLiteDatabase.CursorFactory factory); @Override SQLiteDatabase openOrCreateDatabase(String name, int mode,
            SQLiteDatabase.CursorFactory factory, DatabaseErrorHandler errorHandler); @Override File getFilesDir(); @Override File getExternalFilesDir(String type); @Override File getCacheDir(); @Override File getExternalCacheDir(); @Override SharedPreferences getSharedPreferences(String name, int mode);  }
@Test public void testGetSharedPreferences() { final String testName = "test"; final String testComponentPath = ROOT_DIR + "/" + testName; final Context testContext = new TwitterContext(RuntimeEnvironment.application, testName, testComponentPath); final SharedPreferences pref = context.getSharedPreferences(testName, Context.MODE_PRIVATE); final SharedPreferences testPref = testContext.getSharedPreferences(testName, Context.MODE_PRIVATE); assertNotNull(pref); assertFalse(pref.equals(testPref)); pref.edit().putBoolean(testName, true).commit(); assertFalse(testPref.getBoolean(testName, false)); }