-1

私のアプリはいくつかのデータを収集できますが、これらのデータを SD カードの txt ファイルに出力したいだけです。

何らかの理由で、次のコードは Galaxy では機能しますが、Nexus では機能しません。コードに何か問題があると思います。

//name of the file
        String name = "rawData " + year +
                "-" + month + "-" + date + "- " + hour + ":" + minute+ ".txt";

        // create a folder stores all the txt file.
        File root = new File(Environment.getExternalStorageDirectory(), "rawData");
        if (!root.exists()) {
            root.mkdirs();
        }

        // creates a file and a file writer
        File gpxfile = new File(root, name);
        FileWriter writer = null;
        try {
            writer = new FileWriter(gpxfile);
            Log.d(TAG, "The writer is created");
        } catch (IOException e1) {
            e1.printStackTrace();
        }

        Log.d(TAG, "Is the writer null? " + writer);

ここにログキャットがあります

どうもありがとう!

4

2 に答える 2

1

これを変える

File root = new File(Environment.getExternalStorageDirectory(), "rawData");

File root = Environment.getExternalStorageDirectory();

于 2013-02-02T20:10:38.133 に答える
1

:外部ストレージは通常、ファイル名に文字を使用できない fat32 ファイルシステムです。
ちなみに、使用前に存在を確認する必要はありませんmkdirs()

于 2013-02-02T20:12:44.083 に答える