@SuppressLint("ApplySharedPref")
@Test(expected = TransactionInvalidatedException.class)
public void commitTwice() {

    String value = "value";
    PreferencesEditor editor = preferences.edit()
            .putString(key, value);
    editor.commit();
    editor.commit();
}