不要临时文件会即使在应用程序运行时删除了? [英] Do temporary files get deleted even while the app is running?

查看:302
本文介绍了不要临时文件会即使在应用程序运行时删除了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Android上,你可以创建临时文件本身(链接这里和<一个href=\"http://developer.android.com/reference/java/io/File.html#createTempFile%28java.lang.String,%20java.lang.String,%20java.io.File%29\"相对=nofollow>这里文档):

On android, you can create temporary files as such (link here and here for documentation) :

final File temp = File.createTempFile("myFile", ".tmp", context.getCacheDir());

我开发使用临时文件,当它与他们所做的(并且在应用的开始),它删除他们的应用程序。

I'm developing an app that uses temporary files and when it's done with them (and on start of the app), it deletes them.

该文件说:

在该装置上的内部存储空间,Android版可能会删除
  这些缓存文件来​​恢复空间。

When the device is low on internal storage space, Android may delete these cache files to recover space.

这是否意味着文件可以被删除甚至在我的应用程序仍在运行?在这种情况下,将机器人被允许删除的文件?

Does it mean that files can get deleted even while my app is still running? In which cases would android be allowed to delete the files?

在换句话说,可我认为,只要我有应用程序运行时,机器人本身不会删除该文件,即使其他应用程序创建自己的临时文件?

In other words , can I assume that as long as I have the app running , android won't delete the files by itself, even if other apps create their own temporary files?

推荐答案

您可以测试它。创建新的应用程序,应用程序写入数据到文件,比内部stroge满。当内部stroge全的Andr​​oid删除应用程序缓存目录这1MB以上的应用程序商店。如果应用程序缓存目录看不上,Android的删除,即使在应用程序正在运行。否则,当应用程序运行Android永远不会删除缓存文件。

You will can test it. Create new app, app write data to file and than internal stroge full. When internal stroge full Android delete applications cache directory which app store above 1Mb. If applications cache dir trashed, Android deleted even while the app is running. Otherwise while app running Android never deleted cache files.

这篇关于不要临时文件会即使在应用程序运行时删除了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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