내 응용 프로그램 소리가납니다. 사운드가 녹음되면 새 파일 이름을 입력하라는 메시지가 나타납니다. 이제 내가하려는 것은 텍스트 파일에 모든 파일 이름을 추가하여 나중에 목록 뷰로 만들기위한 배열로 읽을 수 있도록하는 것입니다. 텍스트 파일에 새 텍스트 줄 추가
이
코드입니다 ://this is in onCreate
File recordedFiles = new File(externalStoragePath + File.separator + "/Android/data/com.whizzappseasyvoicenotepad/recorded files.txt");
if(!recordedFiles.exists())
{
try {
recordedFiles.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//this executes everytime text is entered and the button is clicked
try {
String content = input.getText().toString();
FileWriter fw = new FileWriter(recordedFiles.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write(">" + content + ".mp3");
bw.close();
} catch (IOException e) {
e.printStackTrace();
}
이제 문제는 내가 새 파일을 기록하는 매번이며, 이전 줄을 덮어 씁니다. 따라서 'text1'과 'text2'두 파일을 녹음하면 text1을 녹음 한 후 txt 파일에 text1이 표시되지만 text2를 녹음하면 text2가 새 줄을 삽입하는 대신 text1을 덮어 씁니다.
bw.NewLine()
bw.write(">" + content + ".mp3");
전에하지만이 작동하지 않습니다
나는 추가했습니다.
>sound1
>sound2
>sound3
가능한 중복 교체 : http://stackoverflow.com/a/5987040/2500326 예상대로 – Sw4Tish