Thursday, April 12, 2012

Android folder monitor

Am using sdcard for saving data ,my problem is that when app is running and some one delete this folder then the application fail. Is there anyway to notify the app , when this folder get deleted ?. Please help me



Answer:


Try like this.
 private static File logFile = null; 
    String SD_CARD_PATH = Environment.getExternalStorageDirectory().toString(); 
    logFile = new File(SD_CARD_PATH + "/" + "folderName"); 
    if (logFile.exists()){ 
       //exist.so do your work 
    } 
    else{ 
      //not exists 
    } 

1 comment: