简体   繁体   English

我应该删除 Android 应用程序内部存储器中的文件吗?

[英]Should I delete the file in Internal memory on Android App?

My Android Emulator is not working on my computer, for the time being I am testing my app on real devices.我的 Android 模拟器无法在我的计算机上运行,​​目前我正在真实设备上测试我的应用程序。 Here is my question.这是我的问题。

I am saving some text as a text file (let us name it as data.txt ) in the App's internal memory.我将一些文本保存为应用程序内存中的文本文件(让我们将其命名为data.txt )。 I will share this file with certain apps on the installed device.我将与已安装设备上的某些应用程序共享此文件。

The data needs to be saved to the file at frequent intervals (say twice a day).数据需要以频繁的时间间隔(比如一天两次)保存到文件中。 Each time the data is saved under the same file name ( data.txt ).每次数据都保存在相同的文件名( data.txt )下。

I am using FileProvider to share the file with other applications.我正在使用FileProvider与其他应用程序共享文件。

So here is the scenario.所以这是场景。 1st set of data is saved under data.txt .第一组数据保存在data.txt下。 Should I delete this file after sharing?共享后我应该删除这个文件吗? so that the 2nd set of data gets saved under the same file name or does the application takes care of this issue automatically (by simply replacing the file data.txt containing 1st data with the file data.txt containing the 2nd data)?让第二组数据被下相同的文件名保存或应用程序是否会自动进行这一问题的关心(通过简单地更换含第1个数据与文件data.txt中包含第二数据Data.txt文件)?

Data will be overwritten in file when u will write in the code if u look at the constructor of FileOutputStream(String path, boolean append) the Boolean value is to handle either you want to append the file or overwrite the existing file(by default this value is false means it will surely overwrite data ) .如果您查看FileOutputStream(String path, boolean append)的构造函数,当您在代码中写入时,数据将在文件中被覆盖,布尔值是处理您要附加文件或覆盖现有文件(默认情况下,此值为 false 意味着它肯定会覆盖数据)。 So i don't think there is a need to delete your file所以我认为没有必要删除你的文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM