Storing small Key-Value Pairs:
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.
Storing Documents/Database (Sqlite):
Each platform has it's own folder structure to store app specific data/files underneath.
Android:
Environment.SpecialFolder.Personal & MyDocuments
both maps to: /data/data/@PACKAGE_NAME@/files
Environment.SpecialFolder.LocalApplicationData
maps to: /data/data/@PACKAGE_NAME@/files/.local/share
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
all map to: /Documents
iOS has following directory structure:
/Documents
/Library
/Library/Application Support
/Library/Caches
/tmp
/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
: Not visible in iTunes
. Can be backed up by iTunes/iCloud
except Caches
directory.
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).
To get to the Library Path:
Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "..", "Library");
To know more on each Enumeration's mapping with directory Go Here.
Find basics about iOS File System Basics.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…