问题描述
我是 Xamarin.Forms 和移动开发的新手.我想将我的应用程序用户的用户和加密密码存储在移动设备上的文件中.我正在使用 xamarin 表单技术.我知道有很多不同的文件夹.例如:
I'm new in Xamarin.Forms and mobile development. I want to store user and encrypted password of my application user in file on mobile device. I'm using xamarin forms technology. I kwnow that there are many differenet folders. In example:
System.Environment.SpecialFolder.Personal
System.Environment.SpecialFolder.LocalApplicationData
System.Environment.SpecialFolder.MyDocuments
您可以在此处找到完整列表:https://msdn.microsoft.com/en-gb/en-enl/library/system.environment.specialfolder(v=vs.110).aspx
Full list you can find here: https://msdn.microsoft.com/en-gb/en-enl/library/system.environment.specialfolder(v=vs.110).aspx
商店的最佳文件夹/目录是什么:
What is the best folder / catalog for store:
- 用户和密码数据
- 其他应用特定数据
??
我发现个人"对我有好处,但如果您有其他答案,也可以发布.SpecialFolder.个人位置
I have found that "Personal" is good for me, but if you have other answers post it as well. SpecialFolder.Personal location
推荐答案
存储小的键值对:
Xamarin.Forms 实现 应用程序.Current.Properties
将键值数据存储在应用程序的本地存储中,并且只有存储它们的应用程序才能访问这些键值对.
Xamarin.Forms implements Application.Current.Properties
which stores the key value data in the local storage of the app and access to these key-value pairs are secure to that app only who stored them.
存储文档/数据库 (Sqlite):
每个平台都有自己的文件夹结构来存储应用程序特定的数据/文件.
Each platform has it's own folder structure to store app specific data/files underneath.
安卓:
Environment.SpecialFolder.Personal &MyDocuments
都映射到:/data/data/@PACKAGE_NAME@/files
Environment.SpecialFolder.LocalApplicationData
映射到:/data/data/@PACKAGE_NAME@/files/.local/share
我们可以根据文件在文件系统中的映射方式将文件存储在上述任何目录中.以上目录都不能被其他应用访问,除非手机已经root,否则用户也不能在世界之外访问它们.
We can store files in any of the above directories based on how they are mapped in the file system.None of the above directories can be accessed by other app, nor user can access them outside the world unless the phone is rooted.
iOS:
Environment.SpecialFolder.Personal, LocalApplicationData &MyDocuments
全部映射到:/Documents
iOS 的目录结构如下:
iOS has following directory structure:
/Documents
/Library
/Library/Application Support
/Library/Caches
/tmp
/Documents
: 在 iTunes
中可见,如果在 info.plist
中打开了 iTunes 共享应用程序.内容可以通过 iTunes/iCloud
进行备份.
/Documents
: Gets visible in iTunes
If iTunes sharing is turned on in info.plist
in the app. Content can be backed up by iTunes/iCloud
.
/Library
:在 iTunes
中不可见.可以通过iTunes/iCloud
备份,Caches
目录除外.
/Library
: Not visible in iTunes
. Can be backed up by iTunes/iCloud
except Caches
directory.
不需要向用户公开的文件/数据应存储在库目录中.前任.数据库文件.我会去 Library
目录以增加安全性和加密(如果需要).
Files/Data which doesn't need to expose to user should be stored in Library directory. Ex. database files. I would go for Library
directory for add on security along with encryption (if required).
进入图书馆路径:
Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "..", "Library");
要详细了解每个枚举与目录转到此处的映射.
To know more on each Enumeration's mapping with directory Go Here.
查找有关 iOS 的基础知识 文件系统基础知识.
Find basics about iOS File System Basics.
这篇关于在 Xamarin.Forms 中存储应用程序数据的最佳 Environment.SpecialFolder 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!