我有一个文件
String filename="MEMS.backup";
我用它来保存:
InputStream myInput;
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard, "Myfolder");
try {
myInput = new FileInputStream(MyApplication.getAppContext().getFilesDir().getParentFile().getPath()+"/databases/MEMS");
// Create the folder if it doesn't exist:
if (!directory.exists())
{
directory.mkdirs();
}
OutputStream myOutput = new FileOutputStream(directory.getPath()+
filename);
这要加载:
OutputStream myOutput;
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard, "Myfolder");
try {
myOutput= new FileOutputStream(MyApplication.getAppContext().getFilesDir().getParentFile().getPath()+"/databases/MEMS");
InputStream myInputs = new FileInputStream(directory.getPath()+filename);
问题是它在 sdcard 中创建了“Myfolder”,但它是空的。
并且文件“MEMS”只在 sdcard 中(应该在 Myfolder 中)。
并且文件的名称是 MyfolderMEMS 而不是 MEMS。
我想不出我的错误。