I am saving in a key in SharedPreferences. When in try to retrieve it at once, it returns me the value. But after some time it returns a nil value. This particularly happens in Samsung S7 Nougat and works fine for almost all other devices such as Nexus, Mi, Oppo, etc. I cross checked several times but i havent altered the value of the key between saving and retrieval.
I have noticed that Samsung doesnt clear Preferences after uninstalling the app (I checked in Samsung S6).So is there any problem with the Samsung devices or is there any loop hole im not considering. Please help!
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="false"
android:hardwareAccelerated="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:launchMode="singleTask"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".activities.SplashActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<data
android:host=“xx.com"
android:scheme=“xx”
android:pathPrefix="/"/>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<activity
android:name=".activities.MainActivity"
android:launchMode="singleTask"
android:screenOrientation="portrait" />
<activity
android:name=".activities.AutomatedTestActivity"
android:screenOrientation="portrait" />
<activity android:name=".activities.PasswordCancelActivity"></activity>
</application>
I have noticed that Samsung doesnt clear Preferences after uninstalling the app (I checked in Samsung S6).So is there any problem with the Samsung devices or is there any loop hole im not considering. Please help!
Change android:allowBackup:false
in android mainfest application tag.
If its true backup will be stored even if app gets uninstalled.
From android developer docs
android:allowBackup Whether to allow the application to participate in the backup and restore infrastructure. If this attribute is set to false, no backup or restore of the application will ever be performed, even by a full-system backup that would otherwise cause all application data to be saved via adb. The default value of this attribute is true.