java如何将静态日志文件包含到Android应用程序中,并且在关闭应用程序时不会被删除?
我想在我的应用程序中包含一个静态日志文件。每当用户启动应用程序时,会在该文件中附加一个包含额外信息的时间。起初,我认为将文件存储到assets文件夹或raw文件夹是解决方案,但后来我查看了安卓 documentations其中的说明:
Tip: If you want to save a static file in your application at compile time, save the file in your project res/raw/ directory. You can open it with openRawResource(), passing the R.raw. resource ID. This method returns an InputStream that you can use to read the file (but you cannot write to the original file).
我怎样才能解决这个问题
编辑:
我希望在关闭应用程序时不要删除日志文件
# 1 楼答案
你应该在第一次启动时创建日志文件,而不是在应用中包含日志文件
有更多关于创建文件的信息
# 2 楼答案
以下是解决方案: