简体   繁体   中英

Can I restrict my app sharedprefs data to google drive/cloud in android?

I want to restrict my app's privacy data when user backup/restore in other device. Can I set android:allowBackup="false" in manifest file to achieve this?

I am saving unique Id in sharedprefs with uuid.randomstring(). So if user takes backup and restore on other device he should generate unique value. So, I have to restrict sharedprefs value when user enables google sync. To achieve that Can I use android:allowBackup="false"

You can set android:allowBackup="false" to completely disable backup of your app or you can just specify:

<full-backup-content>
    <exclude domain="sharedpref" path="MYUNIQUEIDFILE.xml"/>
</full-backup-content>

to disable backup of the shared preference file where your id is set (see the documentation here ). This also means that if user uninstalls and reinstalls your app in the same device new id will be generated. Or if user clears the data area of the app.

I think ideal solution would be to allow restoration of the backup only to a device where it was taken from, but I don't think that there is defined way to do that. And I have not been able to come up with good solution for that yet.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM