我試圖創建一個目錄,我正在檢查它是否成功創建,但在屏幕上顯示文本,但沒有顯示。檢查一個目錄是否被創建,失敗?
Java代碼:
public void createDirectory() {
try {
String strDirectory = "test";
boolean success = (new File(strDirectory)).mkdir();
if (success) {
Toast.makeText(getBaseContext(), "Directory "+strDirectory+" created", Toast.LENGTH_SHORT);
} else {
Toast.makeText(getApplicationContext(), "error occured", Toast.LENGTH_SHORT);
}
} catch (Exception e) {
Log.e("Error", "Error creating directory");
}
}
沒有Toast出現似乎表明它既沒有「if」也沒有「else」......這意味着有一個例外,它正在做Log.e(...)。你可以發佈logcat嗎? – mfrankli 2012-03-20 18:11:17