您好,登錄后才能下訂單哦!
/** 取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();
}
}
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。