0
我第一次使用內部存儲,而我的openFileOutput給了我一個錯誤。我不知道如何使這項工作,但下面的方法工作完美罰款,如果FileOutputStream被刪除。謝謝!FileOutputStream在Android中不起作用
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);
}
}
錯誤..什麼錯誤? – eltabo
它不識別openFileOutput(FILENAME,Context.MODE_PRIVATE);它建議我用try/catch添加一個throw聲明或環繞聲。謝謝! – user3246935
'openFileOutput'是'ContextWrapper'的一個函數。這個「加法」函數在哪裏聲明? –