안드로이드의 내부 파일에 관한 질문이 있습니다. 파일에 데이터를 쓰려고했지만 다시 읽으려고했지만 파일을 읽을 수없는 것처럼 보입니다. 내가 아래에 사용하기 위해 노력하고있어 코드를 추가 .. .. 나는 두 번 저장하거나 값을 플로트 수 어쨌든이 첫번째 정수로 캐스팅 :내부 기억 장치 읽기/쓰기 안드로이드
FormatCluster formatCluster = ((FormatCluster)objectCluster.returnFormatCluster(ofFormats,"Calibrated"));
if (formatCluster != null) {
//Obtain data for text view
calibratedDataArray[0] = formatCluster.mData;
calibratedUnits = formatCluster.mUnits;
A.setText("data: " + formatCluster.mData);
String filename = "myfile";
//String string = "Hello world!";
FileOutputStream outputStream;
try {
outputStream = openFileOutput(filename, Context.MODE_PRIVATE);
outputStream.write((int)formatCluster.mData);//here I don't want to cast the value to integer
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
//testing.setText)
double ch;
StringBuffer fileContent = new StringBuffer("");
FileInputStream fis;
try {
fis = context.openFileInput(filename);
try {
while((ch = fis.read()) != -1)
testing.setText(fileContent.append(ch));
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
어떤 형식이'FormatCluster.mData'입니까? – dacwe
@dacwe 두 배 – Kopiko