我要把输出流保存到SD卡上去,这样写对么?为何我运行后在ddms上sd卡路径里找不到deme01.txt?
et1=(EditText) findViewById(R.id.ET1);
btn1=(Button) findViewById(R.id.button1);
btn1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
try{
String string=et1.getText().toString();
byte[] buffer=string.getBytes();
FileOutputStream foS=openFileOutput("deme01.txt", MODE_PRIVATE);
foS.write(buffer);
foS.close();
String path=Environment.getDownloadCacheDirectory().getPath();
File myfile01=new File(path+"/deme01.txt");
FileOutputStream foStr=new FileOutputStream(myfile01);
foStr.write(buffer);
foStr.close();
}
catch (Exception e){
e.printStackTrace();}
}
manifest文件如下
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.j.file_01"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.j.file_01.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>