简体   繁体   English

在SharedPreferences中存储Android应用内购买

[英]Store Android in-app purchases in SharedPreferences

Is it okay to store user in-app purchases in SharedPreferences? 将用户应用内购买存储在SharedPreferences中可以吗? Moreover will SharedPreferences (which are saved to user's Google account, if I'm not wrong) will be the same for the app among all user's devices, which use same Google account? 此外,在使用相同Google帐户的所有用户设备中,该应用程序的SharedPreferences(如果我没有记错的话,保存到用户的Google帐户)会相同吗?

No, you shouldn't. 不,你不应该。 If the user deletes the app data via the settings, this will also delete the SharedPreferences. 如果用户通过设置删除应用程序数据,这还将删除SharedPreferences。

Use the API, to query the in-app purchases from the user, which is documented here . 使用API​​查询来自用户的应用内购买,该文档在此处记录

Julian is right, you should always query for the purchases, in onResume() for example. 朱利安是对的,您应该始终查询购买商品,例如在onResume()中。

If you did want to store the product id or part of the receipt in SharedPrefs just make sure to use Context.MODE_PRIVATE and I wouldn't store anything like purchaseToken or orderId . 如果你确实想保存收据SharedPrefs的产品ID或部分只是确保使用Context.MODE_PRIVATE ,我也不会储存像什么purchaseTokenorderId

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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