Ionic 3中Storage类是持久存储还是缓存?能否跨会话读取数据?
Hey there! Let me break down your questions about Ionic 3's Storage class clearly and straightforwardly:
1. Does it retain data after closing the app?
Absolutely! The Storage class in Ionic 3 is built for persistent data storage—your saved data will still be accessible even after you close the app, restart the device, or reboot it entirely. It’s not a temporary in-memory cache that gets wiped as soon as the app exits.
2. Is data saved to physical device storage, or just a temporary cache?
It’s definitely saved to physical device storage, not just a transient cache. Here’s how it works across different platforms:
- Web browsers: Uses
localStorage, which saves data in the browser's persistent storage area - iOS: Leverages either Keychain (Apple's secure, built-in persistent storage system) or SQLite (if you configure it)
- Android: Uses SharedPreferences (stored as XML files in the app's dedicated data directory) or SQLite
All these underlying mechanisms write data directly to the device's physical storage (like internal storage or secure key storage). The data will stay there until you explicitly delete it, or the user uninstalls the app/clears the app's stored data.
To sum it up: Ionic 3's Storage is made for long-term data retention, not temporary session-based caching. You can trust it to keep your data intact between app sessions.
内容的提问来源于stack exchange,提问作者james watt

