[英]Storing small amount of data
我正在构建一个android应用程序,并且我想存储4位数字(pin),而不设置任何数据库。
该4位数字将是该应用的密码。
我知道如何设置SQLite数据库,但仅用4位数字似乎就可以完成很多工作
Android SharedPreferences
将完成以下工作:
var prefs = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
var editor = prefs.Edit();
editor.PutString("MyFourDigitString", "1234");
editor.Apply();
var MyFourDigitString = prefs.GetString("MyFourDigitString", "0000"); // 0000 = default value
要保存信息,您有以下选择:
如果您不想使用SQLite数据库,请使用“共享首选项”。 但是,当用户从设置中删除数据时,它将删除。
请阅读以下网址以获取更多详细信息。
https://developer.android.com/training/basics/data-storage/index.html
https://developer.android.com/guide/topics/data/data-storage.html
干杯!!!
使用共享首选项。 由于您在首选项中存储密码,因此必须将其存储为加密数据。 例子在这里
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.