Anshul Tyagi
Anshul Tyagi

Reputation: 2196

How to access existing SharedPreference by another android app

I'm having an app which is already live on play store and whole data of that app is stored in EncryptedSharedPreferences. I'm using androidx.security.crypto for the SharedPreferences. Now I'm going to have a new app on play store with different package name. So I want to access whole data of that app and transfer into new app. I tried using sharedId but it always returns null to me. Below I'm mentioning the custom shared preferences class what I'm using in an existing app.

class SharedPrefUtils(context: Context) {
private val keyGenParameterSpec = MasterKeys.AES256_GCM_SPEC
private val masterKeyAlias = MasterKeys.getOrCreate(keyGenParameterSpec)
private val PASS_KEY = context.getString(R.string.pass_key)
private val sharedPrefs = EncryptedSharedPreferences.create(
    PASS_KEY,
    masterKeyAlias,
    context,
    EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
    EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
)

So I want to know whether it's possible to access this type of data or not. If not, then what alternatives I can have.

Thanks.

Upvotes: 0

Views: 644

Answers (0)

Related Questions