Android的,文件夹一段时间后删除 [英] Android, folder deleted after some time

查看:336
本文介绍了Android的,文件夹一段时间后删除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序创建一个文件夹,然后在SD卡的XML文件。但一段时间后的文件夹被删除,并用它的文件。该文件被用于存储从所述应用程序中的数据进行备份。

My app is creating a folder and then an xml file on the sdcard. But after some time the folder is deleted and the file with it. The file is used to store a backup of the data from the app.

我不需要新的东西,使备份,但为什么它发生的描述。该文件夹的名称为备份的SD卡的根目录下创建的。

I dont need something new to make backup but a description of why it happens. The folder is created in the root of the sdcard with the name 'backup'.

这是我如何创建文件夹和文件:

This is how I create the folder and file:

File path = new File(Environment.getExternalStorageDirectory() + "/backup/tet/");
path.mkdirs();
File backupdir = new File(path, getDateTime() + ".xml");
fos = new FileOutputStream(backupdir);
fos.write(encodeDb(ctx).getBytes());
fos.close();

这是我如何读文件:

boolean parsed = false;
File file = new File(Environment.getExternalStorageDirectory() + "/backup/tet/" + filename);
fis = new FileInputStream(file);
byte[] buffer = new byte[(int) file.length()];
fis.read(buffer, 0, (int) file.length());
parsed = decodeDb(ctx, new String(buffer));
fis.close();

我希望你能帮助我讨论这个问题。

I hope you can help me to discuss the problem.

推荐答案

也许其他一些应用程序也使用一个名为备份文件夹,然后将其删除?我想不同的命名文件夹,以确保它是特定于您的应用程序。

Maybe some other app also uses a folder named "backup" and then deletes it? I would name the folder differently, to make sure it's specific for your app.

这篇关于Android的,文件夹一段时间后删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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