我想在我的应用程序中包含一个静态日志文件。每当用户启动应用程序时,带有额外信息的时间都会附加到该文件中。一开始,我认为将文件存储到 asset 文件夹或 raw 文件夹中将是解决方案,但后来我查看了 android 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).
如何解决这个问题?
编辑:
我希望日志文件在关闭应用程序时不被删除。
最佳答案
您应该在首次启动时创建日志文件,而不是在应用程序中包含日志文件。
还有更多信息How to create a file in Android?关于创建文件。
关于java - 如何将静态日志文件包含到 Android 应用程序中,该文件在关闭应用程序时不会被删除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8001067/