getApplicationContext()。getFilesDir()“的路径是什么?返回? [英] What path does "getApplicationContext().getFilesDir()" return?
问题描述
我在Android中做一个简单的应用程序,在应用程序的某个部分,我想创建一个Excel文件并写入它。我已经准备好使用jexcel库来编辑使用Java的excel,但是我找不到我创建的Excel文件。我试图找到它在我自己的设备执行该应用程序,但我不能。
I'm doing a simple app in Android and in a certain part of the app I would like to create an Excel file and write in it. I've already prepared everything to use jexcel library to edit an excel using Java, but the thing is I can't find the Excel file I created. I've tried to find it in my own device executing the app, but I couldn't.
String fileName = "hours.xls";
File file = new File(getApplicationContext().getFilesDir() + fileName);
有人可以帮助我吗?
感谢提前:)
推荐答案
在Android KitKat上,它返回 / data / data / {您的包name} / files
,但我想像这可能会根据你的平台版本而改变。因此,如果您只想浏览文件系统并查看文件,则可以安全地使用此路径,但如果您在多个平台版本中使用此路径进行某些功能,则应仅使用 getFilesDir()
。
On Android KitKat, it returns /data/data/{your package name}/files
, however I imagine this could change depending on your platform version. Thus if you're just trying to dig through your filesystem and see a file, it's safe to use this path, but if you're using this path for some functionality across multiple platform versions, you should only reference it using getFilesDir()
.
这篇关于getApplicationContext()。getFilesDir()“的路径是什么?返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!