• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Save to disk problem

bgoody

Well-Known Member
Aug 18, 2009
127
6
Hi. I have this bit of code where I'm trying to save the results of a calculation to disk but it says that the variable (txt) cannot be resolved.
Any ideas!

private void handleEquals(int newOperator) {
if (hasChanged) {
switch (operator) {
case 1:
num = num + Double.parseDouble(txtCalc.getText().toString());
break;
case 2:
num = num - Double.parseDouble(txtCalc.getText().toString());
break;
case 3:
num = num * Double.parseDouble(txtCalc.getText().toString());
break;
case 4:
num = num / Double.parseDouble(txtCalc.getText().toString());
break;
}

String txt = Double.toString(num);
txtCalc.setText(txt);
txtCalc.setSelection(txt.length());

readyToClear = true;
hasChanged = false;

}

FileOutputStream fOut = openFileOutput("samplefile.txt",MODE_WORLD_READABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
osw.write(txt);
osw.flush();
fOut.close();
osw.close();
operator = newOperator;

}
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones