1. 使用SharedPreferences保存文件路径,获取保存的文件路径 SharedPreferences是Android提供用来存储一些简单的配置信息的一种机制,例如,一些默认欢迎语、登录的用户名和密码的存储等。 /** 保存文件目录 */ public static final String PREF_INFO = "Directory_PrefInfo"; //常量定义 public static final String PREF_INFO = "File directory"; //以指定名字来创建 SharedPreferences pref = getSharedPreferences(PREF_INFO, MODE_PRIVATE); SharedPreferences.Editor editor = pref.edit(); //以键值<String Key,String Value> 的方式加入数据 editor.putString(TAG_NAME, "/sdcard/default/"); //使用SharedPreferences.Editor来提交数据 editor.commit(); /** 获取保存的文件目录 */ String dir = ""; SharedPreferences pref = this.getSharedPreferences(PREF_INFO, MODE_PRIVATE); //以 String Key 为索引来取出数据 dir = pref.getString(TAG_NAME, "");