Dee*_*ool 1 java eclipse android adk
我正在开发一个Android应用程序,我需要将数据写入文本文件,以便稍后在其他活动中阅读.这是我的代码正文.
//writes the string "hello android" to file
FileOutputStream outFile = openFileOutput("myfile.txt", MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(outFile);
String hello = "hello android.";
osw.write(hello);
osw.flush();
osw.close();
Run Code Online (Sandbox Code Playgroud)
当我第一次写这段代码时,我收到了一个警告,所以我添加了这一行
@SuppressWarnings("deprecation")
Run Code Online (Sandbox Code Playgroud)
到我的功能的顶部.但是,我的IDE中仍然会删除MODE_WORLD_READABLE.为什么?注意:该函数具有try-catch语句,它们应该是,并且"在函数顶部抛出IOException.
| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |