如题,照着第一行代码打的,没有报错,什么都没有,可是就是没有输出文件,连安装路径都没有不要说该路径下写文件,代码如下
package com.yzx.example.filepersistencetest;
import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.widget.EditText;
public class MainActivity extends Activity {
private EditText edit;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
edit=(EditText)findViewById(R.id.edit);
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
String inputText=edit.getText().toString();
save(inputText);
super.onDestroy();
}
public void save(String inputText){
FileOutputStream out=null;
BufferedWriter writer=null;
try{
out=openFileOutput("heheha.txt",Context.MODE_PRIVATE);
writer=new BufferedWriter(new OutputStreamWriter(out));
writer.write(inputText);
}catch(IOException e){
e.printStackTrace();
}finally{
try{
if(writer!=null){
writer.close();
}
}catch(IOException e){
e.printStackTrace();
}
}
}
}
自己试着手动去android/data/目录下创建了<包名>/files文件夹,可是也没有用,求大神帮忙看看