android内部空间写文档

来源:互联网 发布:windows md文件编辑器 编辑:程序博客网 时间:2024/05/17 04:05
SharedPreferences sp=getSharedPreferences("info",MODE_PRIVATE);  //文档类型为xml 的  这是写入
Editor editor= sp.edit();
editor.putString("name","name");
editor.putString("pass","pass");

editor.commit();


SharedPreferences sp=getSharedPreferences("info",MODE_PRIVATE);  这是读取里面的内容
sp.getString("name", "");

Toast.makeText(this,sp.getString("pass", "") , 1).show();


FileOutputStream fos=openFileOutput("info2.txt",MODE_WORLD_WRITEABLE); //可以设置其他用户对文件的读写权限

fos.write("haha".getBytes());
fos.close();


FileOutputStream fos=openFileOutput("info.txt",MODE_PRIVATE);
fos.write("haha".getBytes());
fos.close();

0 0