2016-06-19 6 views
2

下記のコードを使用してアンドロイドのテキストファイルにデータを追加しようとしていますが、1行のデータだけを上書きします。Androidのテキストファイルにデータを追加する

private void copyImageToMemory(File outFile , Float number) { 
    try { 

     BufferedOutputStream fos = new BufferedOutputStream(
       new FileOutputStream(outFile)); 


     PrintWriter pw = new PrintWriter(new BufferedWriter(
       new OutputStreamWriter(fos))); 

     pw.append("result"+number); 
     pw.close(); 
     maxSpeed=0; 

    } catch (FileNotFoundException e) { 
     Log.e(TAGFile, "FileNotFoundException"); 
    } 
} 
+0

[Android append text file](http://stackoverflow.com/questions/4542318/android-append-text-file)の可能な複製 –

+0

これは他の種類のファイル用です。 – Amir

答えて

3

FileOutputStreamコンストラクタは、それが既存のファイルに追加すべきか否かを指定することができます:

new FileOutputStream(file, true); 

は、指定されたファイルに追加ストリームを作成します。

関連する問題