我想将我的内部存储文件保存到我的应用创建的文件夹中。请有人建议我怎么可能。 我的代码:
File sub = new File("/sdcard/myfiles");
sub.mkdirs();
FileOutputStream fout;
try {
fout = openFileOutput("MyPrefs" ,Context.MODE_PRIVATE);
String data="Welcome to Android Internal Storage";
fout.write(data.getBytes());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
答案 0 :(得分:1)
尝试此保存:
//write file
File log = new File("sdcard/MyDirectory/MyFile.txt");
try
{
if (!log.exists())
{
//System.out.println("We had to make a new file.");
log.createNewFile();
}
FileWriter fileWriter = new FileWriter(log, true);
BufferedWriter bufferedWriter = new BufferedWriter(fileWriter);
bufferedWriter.write("dataaaa"+ "%" + "moreDataaa"+ "%" + "moreMoreDataaa");
bufferedWriter.write("******************** " + "\n");
bufferedWriter.close();
//System.out.println("Done");
} catch (IOException e)
{
//System.out.println("COULD NOT LOG!!");
}