Android应用程序数据存储不断增加
我正在开发一个 Android 应用程序,它基本上加载新闻文章列表,并在用户单击时在网络视图中打开它们。
我想知道的是,当我在“设置”->“应用程序”->“管理应用程序”中查看应用程序详细信息时,总存储大小不断增加。特别是,数据存储大小正在增加。当然,应用程序的大小是固定的。
据我所知,共享首选项占用数据存储。我不知道还有什么。在我的应用程序中,我只有 1 个复选框首选项和一个包含 4 个项目的列表首选项。
我还实现了 onSaveInstanceState()
方法,其中我只保存一个 int 值并在 onCreate()
期间再次读取。
数据存储大小的增加是正常的还是我遗漏了什么?也许我应该在代码中进行一些内存使用清理?
顺便说一句,我的应用程序有相当大的缓存大小,因为 webview 可能缓存了一些图像,但我不知道是什么导致数据存储不断增加。
I am developing an android app that basically loads up a list of news articles and opens them up in a webview upon user click.
What I'm wondering about is when I look at my app details in 'Settings->Applications->Manage Applications', the Total storage size keeps increasing. Particularly, the data storage size is increasing. The Application size of course, is fixed.
From what I know, the sharedpreferences take up data storage. I don't know what else. In my app, I just have 1 checkbox preference and a listpreference with 4 items.
I also implemented the onSaveInstanceState()
method where I just save a single int value and read up again during onCreate()
.
Is the increasing data storage size normal or am I missing something? Maybe there should be some memory use cleanup I should do in my code?
By the way, my app has quite a big cache size due to the webview caching some images maybe but I don't know what makes the data storage keeps increasing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这已经超过两年了,但对其他人可能有用。我发现问题出在
WebView
中,而不是在SharedPreferences
中我遇到了同样的问题,并通过以下方式重写
onPause()
方法解决了:clearCache 方法采用一个布尔参数,让您指定是否要包含 WebView 存储的磁盘文件。如果启用它,您的数据使用量将显着减少。希望有帮助!
I know that is over 2 years, but it could be useful for someone else. I discovered that the problem resides in the
WebView
and not in theSharedPreferences
I had the same problem and solved by overriding the
onPause()
method in this way:The clearCache method takes a boolean argument that lets you specify whether you want to include disk files that the WebView stores. If you enable it your data usage will significantly decrease. Hope it helps!