일부 데이터를 저장하려면 아래 함수를 사용하고 있습니다. mydata는 사용자가 입력하는 이중 목록이고 dates_Strings는 문자열 형식의 날짜를 포함하는 list (데이터 유형은 String)입니다. "2"+ 저장 "3"+ 저장 + "4"+,파일을 저장하면 많은 변수가 생성됩니다.
예를 들어것은 내가 "1"+ 저장 입력하는 경우 :
public void savefunc(){
SimpleDateFormat thedate = new SimpleDateFormat("dd/MM/yyyy",Locale.US);
Date d=new Date();
String formattedDate=thedate.format(d);
dates_Strings.add(formattedDate);
double thedata=Double.parseDouble(value.getText().toString().trim());
mydata.add(thedata);
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard, "MyFiles");
directory.mkdirs();
File file = new File(directory, filename);
FileOutputStream fos;
try {
fos = new FileOutputStream(file,true);
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(fos));
for (int i=0;i<mydata.size();i++){
bw.write(mydata.get(i)+","+dates_Strings.get(i)+"\n");
}
value.setText("");
bw.flush();
bw.close();
} catch (IOException e2) {
e2.printStackTrace();
}//catch
}
이제 문제는 다음을 저장할 때하는 일이다 > 07/05/13
1.0 - -> 07/05/13
,536 내가1.0을 볼 수있는 파일에서 ...
을 저장
2.0 -> 07/05/13
3.0 -> 07/05/13
3.0 -> 07/05/13
4.0 -> 07/05/13
를 작성하고 당신은 무엇을 일이 기대
대신
의? – Thrakbad@Thrakbad : "1"을 2 회 또는 3 회가 아닌 한 번만 입력합니다. – George
mydata가 선언 된 위치는 어디입니까? – TactMayers