/** 取SD卡路径 **/
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:域名注册、网络空间、营销软件、网站建设、上城网站维护、网站推广。
private String getSDPath() {
File sdDir = null;
boolean sdCardExist = Environment.getExternalStorageState().equals(
android.os.Environment.MEDIA_MOUNTED);
// 判断sd卡是否存在
if (sdCardExist) {
sdDir = Environment.getExternalStorageDirectory();
// 获取根目录
}
if (sdDir != null) {
return sdDir.toString();
} else {
return "";
}
}
/** 保存密码文件路径 **/
private String getDirectory() {
String dir = getSDPath() + "/" + "QQTSAVE";
File file = new File(dir);
if (!file.exists()) {
try {
file.mkdirs();
} catch (Exception e) {
e.printStackTrace();
}
}
return dir;
}
private void toSave(String user, String password) {
File file = new File(getDirectory() + "/" + "us.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
FileWriter fw = new FileWriter(file);
fw.write(user + "asd" + password);
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public String Read() {
String sb = "";
BufferedReader br;
try {
br = new BufferedReader(new FileReader(getDirectory() + "/" + "us.txt"));
String line = "";
while ((line = br.readLine()) != null) {
sb=line;
}
br.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Log.e("--------------", sb);
return sb;
}
public void deleteSave(String user){
File file = new File(getDirectory() + "/" + "us.txt");
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
FileWriter fw = new FileWriter(file);
fw.write(user+"null");
fw.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}