Changing resource / code path for pkg when updating Android application

If I update my application with a new version, sharedPreferences are deleted.

LogCat says: Package de.xxx.yyy codePath changed from /data/app/de.xxx.yyy-1.apk to /data/app/de.xxx.yyy-2.apk; Locking data and using new

The package is the same as before.

The manifest file changes are as follows:

android:versionCode="6" -> android:versionCode="7"
android:versionName="1.6.000" -> android:versionName="1.8"

and added permission:

<uses-permission android:name="android.permission.VIBRATE" />

Why a new installation path and new data? Does anyone know what happened?

Update Maybe a bogey is a problem. ??? New sharedPreferences have different trailing letters.

OLD: de.xxx.yyy.a.f.xml
NEW: de.xxx.yyy.a.h.xml

I get the name from the class.

SharedPreferences mPrefs = activity.getSharedPreferences(
                THECLASS.class.getName(), Activity.MODE_PRIVATE);
+4
source share
1 answer

.

String sharedPreferences .

Proguard , , - . proguard .

SharedPreferences mPrefs = activity.getSharedPreferences(
                YOURSTRING, Activity.MODE_PRIVATE);
+4

Source: https://habr.com/ru/post/1525613/


All Articles