@@ -44,13 +44,17 @@ public UpdateContext(Context context) {
4444 String storedPackageVersion = this .sp .getString ("packageVersion" , null );
4545 String storedBuildTime = this .sp .getString ("buildTime" , null );
4646
47- // If stored versions don't exist, write current versions first
48- if ( storedPackageVersion == null || storedBuildTime == null ) {
49- SharedPreferences . Editor editor = sp . edit ();
47+
48+ SharedPreferences . Editor editor = this . sp . edit ();
49+ if ( storedPackageVersion == null ) {
5050 editor .putString ("packageVersion" , packageVersion );
51- editor .putString ("buildTime" , buildTime );
5251 editor .apply ();
5352 storedPackageVersion = packageVersion ;
53+ }
54+
55+ if (storedBuildTime == null ) {
56+ editor .putString ("buildTime" , buildTime );
57+ editor .apply ();
5458 storedBuildTime = buildTime ;
5559 }
5660
@@ -65,10 +69,7 @@ public UpdateContext(Context context) {
6569 editor .clear ();
6670 editor .putString ("packageVersion" , packageVersion );
6771 editor .putString ("buildTime" , buildTime );
68- // Use commit() instead of apply() to ensure synchronous write completion
69- // This prevents race condition where getBundleUrl() might read null values
70- // if called before apply() completes
71- editor .commit ();
72+ editor .apply ();
7273 }
7374 }
7475
0 commit comments