Android应用程序无法第二次写入文件
我在 Android 模拟器中将数据写入文件时遇到问题。在我的 Android 模拟器中的 /data 文件夹中,我创建了 MyLogs 文件夹并授予其完全访问权限。运行应用程序后,它会创建 Log.txt 文件并将其放置在 /data/MyLogs 文件夹中。一切都好。在我第二次运行我的应用程序后,应用程序尝试在同一个文件中写入一些信息,但它不能。
我认为主要原因是,我的应用程序第一次创建文件时,创建者与第二次不同。这就是为什么我无法第二次写入文件!
谁有什么想法?
I have problem with writing data to file in Android Emulator. In my Android Emulator in /data folder I have created MyLogs folder and give full access to it. After I run my application and it create Log.txt file and place it in /data/MyLogs folder. All is Okay. After I have run my application in second time and application try to write some information in same file, but it cant't.
I think the main reason is that then at first time my application creates file the creator is different from second time. thats why I can't write to file second time !
Who have any ideas ?
要使文件可多次写入,请使用
Context.MODE_APPEND
示例代码
谢谢
迪帕克
To make a file writable for more than once use
Context.MODE_APPEND
Sample Code
Thanks
Deepak