try {
/*打开文件输出流,名称txtME,以不覆盖模式打开*/
os = this.openFileOutput("txtME", MODE_PRIVATE);/*把字符串转换成字节数组,写入文件中*/
os.write(Text_of_input.getBytes());} catch (FileNotFoundException e) {......
}
文件txtME是在什么目录下? 怎么找不到?
/*打开文件输出流,名称txtME,以不覆盖模式打开*/
os = this.openFileOutput("txtME", MODE_PRIVATE);/*把字符串转换成字节数组,写入文件中*/
os.write(Text_of_input.getBytes());} catch (FileNotFoundException e) {......
}
文件txtME是在什么目录下? 怎么找不到?
这个目录下!!
/data/data/你的程序包名/files/txtME两种方法查看:一:DDMS中查看二:进入dos环境,adb shell进入android系统目录cd 进入上面的那个目录也可以查看楼主试试吧@
比如保存到sdcard卡吧!!File file=new File("/sdcard/txtME.txt");
FileOutputStream fos=new FileOutputStream(file);
String str="awefawe"
fos.write(str.getBytes());这样就可以将txtMe.txt保存到sdcard中!
也可以打开文件!
楼主试试吧!!
---------------------------------------------
要不要这样:
File file=new File("//sdcard//txtME.txt");
写死了不太好。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myfilewriteread"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".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>
2.2及2.2以后的 是/mnt/sdcard用下面的试试吧!!File file=new File(Environment.getExternalStorageDirectory().getPath()+"/txtMe.txt");
FileOutputStream fos=new FileOutputStream(file);
String str="awefawe"
fos.write(str.getBytes());
FileOutputStream fos=new FileOutputStream(file);
String str="awefawe"
fos.write(str.getBytes());-----> 语法上有问题, 代码上会有红叉.
// TODO Auto-generated method stub
File file=new File(Environment.getExternalStorageDirectory().getPath()+"/1.txt");
try {
FileOutputStream fos=new FileOutputStream(file);
String str="awefawef";
fos.write(str.getBytes());
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
在AndroidManifest.xml中加入权限!
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>再不行 我都要跳楼啦 呵呵呵.....
试试吧!楼主!
这个/data/data/你的程序包名/files/txtME 文件是存在本地硬盘哪里的?(比如数据库那些)