EditTextに入力した単語をSDカードのテキストファイルに保存するプログラムを作っています。ただし、タブレットにSDカードをマウントするのに問題があるため、代わりにテキストファイルを内部ストレージに保存することを考えています。誰かがこれを内部ストレージに切り替える方法を教えてもらえますか?コメントをいただければ幸いです。ありがとうございます。
これが私のコードです:
public void writeToSDFile() {
File root = android.os.Environment.getExternalStorageDirectory();
tv.append("\nExternal file system root: "+root);
File dir = new File (root.getAbsolutePath());
dir.mkdirs();
File file = new File(dir, "wordlist.txt");
try {
FileOutputStream f = new FileOutputStream(file);
PrintWriter pw = new PrintWriter(f);
pw.println(stringword);
pw.append(stringword);
pw.flush();
pw.close();
f.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
Log.i(TAG, "******* File not found.");
} catch (IOException e) {
e.printStackTrace();
}
tv.append("\n\nFile written to "+file);
}//end writeToSDFile