在 android 中的文件中输入数据

下面的代码重写了文件。
我想让原来的数据还保持一致。

osw..append (data);  

但是没有获得结果。

public void WriteSettings(Context context, String data){ 
             FileOutputStream fOut = null; 
             OutputStreamWriter osw = null;

             try{
              fOut = context.openFileOutput("abc.txt",Context.MODE_PRIVATE);       
              osw = new OutputStreamWriter(fOut); 
              osw.write(data); 
              osw.flush(); 
              Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show();
              } 
              catch (Exception e) {       
              e.printStackTrace(); 
              Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();
              } 
              finally { 
                 try { 
                        osw.close(); 
                        fOut.close(); 
                        } catch (IOException e) { 
                        e.printStackTrace(); 
                        } 
              } 
         }

public FileOutputStream(File file, boolean append) 构造方法有个已追加方式写入文件
第二个构造函数设置为true就OK

试一下这个DHUDFN

 public void WriteSettings(Context context, String data){ 
         FileOutputStream fOut = null; 
         OutputStreamWriter osw = null;

         try{
          fOut = context.openFileOutput("abc.txt",Context.MODE_APPEND);       
          osw = new OutputStreamWriter(fOut); 
          osw.write(data); 
          osw.flush(); 
          Toast.makeText(context, "Settings saved",Toast.LENGTH_SHORT).show();
          } 
          catch (Exception e) {       
          e.printStackTrace(); 
          Toast.makeText(context, "Settings not saved",Toast.LENGTH_SHORT).show();
          } 
          finally { 
             try { 
                    osw.close(); 
                    fOut.close(); 
                    } catch (IOException e) { 
                    e.printStackTrace(); 
                    } 
          } 
     }