ファイルへの書き込みに問題があります。EditText が空の場合、単一のスペース文字を書きたいか-
、ファイルに書き込みたいのですが、条件が単に無視されます。
これは機能しておらず、その理由がわかりません:
public void onClick(View v) {
// TODO Auto-generated method stub
if(isthereafile == true){
questioncount++;
questiontext = question.getText().toString();
correctanswertext = correctanswer.getText().toString();
wronganswertext1 = wronganswer1.getText().toString();
wronganswertext2 = wronganswer2.getText().toString();
textpathofpic = pathofpic.getText().toString();
try {
FileWriter writer = new FileWriter(test,true);
if(question.getText().toString().equals("") == false){
writer.append(questiontext + ";");}
if(correctanswer.getText().toString().equals("") == false){
writer.append(correctanswertext + ";");}
if(wronganswer1.getText().toString().equals("") == false){
writer.append(wronganswertext1 + ";");}
if(wronganswer2.getText().toString().equals("") == false){
writer.append(wronganswertext2 + ";");}
if(pathofpic.getText().toString().equals("") == false){
writer.append(textpathofpic + ";");}
if(question.getText().toString().equals("")){writer.append("-");}
if(correctanswer.getText().toString().equals("")){writer.append("-");}
if(wronganswer1.getText().toString().equals("")){writer.append("-");}
if(wronganswer2.getText().toString().equals("")){writer.append(" ");}
writer.flush();
writer.close();
question.setText("");
correctanswer.setText("");
wronganswer1.setText("");
wronganswer2.setText("");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});