我有一个关于android内部文件的问题..我试图写入一些数据到一个文件,然后读回来,但是,它似乎我不能写入数据到文件,除非我将其转换为整数第一..反正是有,我可以节省两倍或浮动值..我说我想用下面的代码:读/写内部存储android
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 2013-05-02 13:18:15
@dacwe是双重的 – Kopiko 2013-05-02 13:21:22