我第一次使用内部存储,我的 openFileOutput 给了我一个错误。我不知道如何使这项工作,但如果 FileOutputStream 被删除,下面的方法工作得很好。谢谢!
public void Addition(View view) {
int num1 = numberone.getText().toString().trim().length();
int num2 = numbertwo.getText().toString().trim().length();
String numone = numberone.getText().toString();
String numtwo = numbertwo.getText().toString();
if(num1 == 0 || num2 == 0){
TextView value = (TextView)findViewById(R.id.answer);
value.setText("Numbers not entered");
}
else if(numone.equals("+") || numtwo.equals("+") || numtwo.equals("-") || numone.equals("-")){
TextView value = (TextView)findViewById(R.id.answer);
value.setText("Please enter numbers");
}
else{
answer = Float.parseFloat(numberone.getText().toString()) + Float.parseFloat(numbertwo.getText().toString());;
TextView value = (TextView)findViewById(R.id.answer);
value.setText("Your sum is " + answer);
FileOutputStream fos = openFileOutput(FILENAME, Context.MODE_PRIVATE);
}
}