我已經使按鈕的單擊事件上的目錄製作代碼。但我無法創建目錄。以前,我可以輕鬆做到,但現在有一些麻煩,我沒有成功。請幫助。無法在SD卡中創建DIR
代碼:
button1.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Username = username.getText().toString();
Password = password.getText().toString();
if (Username.length() == 0) {
Toast.makeText(getBaseContext(), "Please Fill Username ",
Toast.LENGTH_LONG).show();
} else if (Password.length() == 0) {
Toast.makeText(getBaseContext(), "Please Fill Password ",
Toast.LENGTH_LONG).show();
} else {
SaxParser(Username, Password);
//new AddTask().execute();
if (str_getValue.equalsIgnoreCase("0")) {
Toast.makeText(getBaseContext(),
"Incorrect Username or Password",
Toast.LENGTH_LONG).show();
} else {
File folder = new File(Environment
.getExternalStorageDirectory()
+ "/audiometer/video");
boolean success = false;
if (!folder.exists()) {
success = folder.mkdir();
}
if (!success) {
// Do something on success
if(login_checkBox_remember.isChecked()==true)
{
SavePreferences("MEM1",Username);
SavePreferences("MEM2",Password);
SavePreferencesBool("flag",true);
}
i.putExtra("value", str_getValue);
i.putExtra("machineName", str_Machinename);
startActivity(i);
} else {
}
}
}
}
});
我也給出WriteExternalStorage
許可清單中。
您是否獲得有關故障或類似的東西的任何消息? – Orest 2012-01-31 09:50:09
你有什麼錯誤嗎? – 2012-01-31 09:50:29