我想生成一个xml文件.保存用户操作的数据.
            OutputStream os = openFileOutput(path, MODE_PRIVATE);
      OutputStreamWriter osw = new OutputStreamWriter(os);
      osw.write(txt);
       osw.close();
       os.close();
总是无法创建?
  

解决方案 »

  1.   

    如何想写在在SD卡上的话,需要在AndroidManifest.xml中加入下面的内容<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
      

  2.   

    向SD卡是要权限的基本配置就用SharedPreferences
      

  3.   

    FileOutputStream fos = this.openFileOutput("xml",Context.MODE_APPEND);
    byte[] b = new byte[1024];
    fos.write("  ".getBytes());
    fos.flush();
    fos.close();
    this就是Activity有异常,需要捕捉