Android 和 iOS 上的本地存储有多持久? [英] How permanent is local storage on Android and iOS?

查看:23
本文介绍了Android 和 iOS 上的本地存储有多持久?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的应用在手机上本地存储数据时,该存储的持久性如何?我会详细说明具体情况:

When my app stores data locally on a phone, how permanent is that storage? I'll elaborate the exact situation:

我正在使用 jQueryMobile 和 Phonegap 构建一个应用程序.它本质上是一个浏览器应用程序,但使用 Phonegap 可以让我将其打包并在应用程序商店中销售,还有其他优势.

I'm building an app with jQueryMobile and Phonegap. It's essentially a browser app, but using Phonegap lets me package it and sell it in the app stores, among other advantages.

Phonegap 提供两种存储方式,这两种功能都协调了 iO、Android、Blackberry 和其他一些操作系统的本机功能:localStorage(这是原始键值对)和 Web SQL 数据库.localStorage 和 web SQL 都是属于浏览器的存储形式.话虽如此,我不知道数据会保留多长时间,在什么情况下会被删除,在什么情况下可能不可用等等.

Phonegap offers two ways of storage, both of which functions harmonize native functions of iOs, Android, Blackberry and some other OSs: localStorage (which is primitive key-value pairs), and a Web SQL database. Both localStorage and web SQL are forms of storage that belong to the browser. Having said that, I can't find out how long the data will stay stored, under what circumstances it will be deleted, under what circumstances it may not be available, etc.

例如,如果应用程序使用 localStorage 或 Web SQL 存储数据,并且用户在其 Android 上切换到不同的标准浏览器,应用程序是否会使用新浏览器打开,这是否意味着存储的数据不可用?

For example, if the app stores data with localStorage or web SQL, and the user switches to a different standard browser on their Android, will the app be opened with the new browser and does that mean that the stored data is unavailable?

如果用户一年不使用该应用程序(在我的情况下这是一个现实的情况,不一定是坏的情况),数据是否会像 cookie 一样过期,或者可能被从浏览器的存储中推出来自其他应用的大量数据?

If the user doesn't use the app for a year (which in my case is a realistic and not necessarily a bad scenario), will the data have expired like a cookie, or maybe been pushed out of the browser's storage by a deluge of data from other apps?

或者数据会更早被销毁,比如什么时候:- 用户在浏览器中访问另一个站点- 浏览器被手动关闭- 浏览器进程被杀死或死亡- 等

Or will the data be destroyed even earlier, such as when: - user visits another site in the browser - browser is manually closed - browser process is killed or dies - etc

或者 localStorage 和 Web SQL 是那种只有在(在 Android 中)您转到设置">应用"并主动删除与应用关联的用户数据时才会删除的存储?

Or are localStorage and web SQL the kind of storage that you only delete when (in Android) you go to Settings > Apps and actively remove the user data associated with the app?

感谢您的任何见解.ol' WWW 上没有任何信息.

Thanks for any insights. There's nothing informative out there on ol' WWW.

应用更新时会发生什么.本地和网络存储会被删除还是会保留?

What happens in the case of app update. The local and web storage will get deleted or will it stay?

推荐答案

让我一步一步来回答

如果应用程序使用 localStorage 或 Web SQL 存储数据,并且用户在他们的 Android 上切换到不同的标准浏览器,使用新浏览器打开应用程序,这是否意味着存储的数据不可用?

if the app stores data with localStorage or web SQL, and the user switches to a different standard browser on their Android, will the app be opened with the new browser and does that mean that the stored data is unavailable?

数据保存在浏览器的缓存"(它不完全是缓存)中,因此如果您更改浏览器,或设置设置以便删除或更改默认浏览器,数据将消失.

The data is saved in the 'cache'(its not exactly the cache) of the browser, so if you change the browser, or set the settings so that the default browser is removed or changed, the data will go.

如果用户一年不使用该应用程序(在我的情况下是现实的,不一定是坏的情况),数据是否有像 cookie 一样过期,或者可能被推出浏览器来自其他应用的大量数据存储?

If the user doesn't use the app for a year (which in my case is a realistic and not necessarily a bad scenario), will the data have expired like a cookie, or maybe been pushed out of the browser's storage by a deluge of data from other apps?

不,无论多长时间不使用,数据都会保留在那里.所以即使你清除了浏览器缓存,它仍然存在.

No, the data will stay there no matter for how long it is not used. So even if you clear the browser cache, it will still be there.

或者数据会更早被销毁,比如什么时候: - 用户在浏览器中访问另一个站点 - 浏览器被手动关闭 -浏览器进程被杀死或死亡 - 等等

Or will the data be destroyed even earlier, such as when: - user visits another site in the browser - browser is manually closed - browser process is killed or dies - etc

不,数据保持正常.:-)

No, the data stays all right. :-)

或者 localStorage 和 web SQL 是您唯一的存储类型删除时(在 Android 中)您转到设置">应用程序"并主动删除与应用关联的用户数据?

Or are localStorage and web SQL the kind of storage that you only delete when (in Android) you go to Settings > Apps and actively remove the user data associated with the app?

是的,只有当您从应用中手动删除数据或卸载应用时,数据才会消失.它将保留在所有其他情况下.

Yes, the data only goes if you either manually delete it from your app or you uninstall your app. It will stay in all other cases.

对于iOS,当设备内存不足时,操作系统会删除本地存储中的数据.

In the case of iOS, the OS will remove the data in the local storage when there is a shortage of memory in the device.

这篇关于Android 和 iOS 上的本地存储有多持久?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆