Skip to content

Commit dec7d4d

Browse files
authored
E2-1537: add method to clear content (#219)
* add method to clear user content locally
1 parent 831218a commit dec7d4d

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

AndroidSDKCore/src/main/java/com/leanplum/Leanplum.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2142,4 +2142,13 @@ private static void parseVariantDebugInfo(JSONObject response) {
21422142
VarCache.setVariantDebugInfo(variantDebugInfo);
21432143
}
21442144
}
2145+
2146+
/**
2147+
* Clears cached values for messages, variables and test assignments.
2148+
* Use sparingly as if the app is updated, you'll have to deal with potentially
2149+
* inconsistent state or user experience.
2150+
*/
2151+
public static void clearUserContent() {
2152+
VarCache.clearUserContent();
2153+
}
21452154
}

AndroidSDKCore/src/main/java/com/leanplum/internal/VarCache.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,22 @@ public static void saveUserAttributes() {
901901
SharedPreferencesUtil.commitChanges(editor);
902902
}
903903

904+
public static void clearUserContent() {
905+
vars.clear();
906+
variants.clear();
907+
variantDebugInfo.clear();
908+
909+
diffs.clear();
910+
messageDiffs.clear();
911+
messages = null;
912+
userAttributes = null;
913+
merged = null;
914+
915+
devModeValuesFromServer = null;
916+
devModeFileAttributesFromServer = null;
917+
devModeActionDefinitionsFromServer = null;
918+
}
919+
904920
/**
905921
* Resets the VarCache to stock state.
906922
*/

0 commit comments

Comments
 (0)