private boolean deleteFile ( File fileToDelete ) { boolean deleted = false ; try { deleted = fileToDelete . delete ( ) ; if ( ! deleted ) { Logger . error ( LOG_TAG , "Unable to delete: " + fileToDelete . getAbsolutePath ( ) ) ; } else { Logger . info ( LOG_TAG , "Successfully deleted: " + fileToDelete . getAbsolutePath ( ) ) ; } } catch ( Exception exc ) { Logger . error ( LOG_TAG , "Error while deleting: " + fileToDelete . getAbsolutePath ( ) + " Check if you granted: android.permission.WRITE_EXTERNAL_STORAGE" , exc ) ; } return deleted ; }
Tries to delete a file from the device . If it fails the error will be printed in the LogCat .