Writing a file to sdcard

后端 未结 3 1791
野性不改
野性不改 2020-11-27 05:44

I\'m trying to write a file from an Http post reply to a file on the sdcard. Everything works fine until the byte array of data is retrieved.

3条回答
  •  悲哀的现实
    2020-11-27 06:11

    Here is a sample:

    // Log used as debug
    File log = new File(Environment.getExternalStorageDirectory(), "Log.txt");
    try {
        out = new BufferedWriter(new FileWriter(log.getAbsolutePath(), false));
        out.write(new Date().toString());
        out.write(" : \n");
    } catch (Exception e) {
        Log.e(TAG, "Error opening Log.", e);
    }
    

提交回复
热议问题