Androidシステムで簡単なテキストファイルに書き込もうとしています。これは私のコードです:Android - 読み取り専用ファイルシステムIOException
public void writeClassName() throws IOException{
String FILENAME = "classNames";
EditText editText = (EditText) findViewById(R.id.className);
String className = editText.getText().toString();
File logFile = new File("classNames.txt");
if (!logFile.exists())
{
try
{
logFile.createNewFile();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try
{
//BufferedWriter for performance, true to set append to file flag
BufferedWriter buf = new BufferedWriter(new FileWriter(logFile, true));
buf.append(className);
buf.newLine();
buf.close();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
しかし、このコードは「にjava.io.IOExceptionを:オープンに失敗しました:EROFS(読み取り専用ファイルシステム)」を生成するエラー。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="hellolistview.com"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".ClassView"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".AddNewClassView"
/>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
誰もが、問題が何であるか任意のアイデアを持っている:私は次のように成功しません、私のマニフェストファイルへのアクセス権を追加しようとしていますか?
これは私のために働きました。ありがとう。 –