Sunday, December 23, 2012

BlackBerry Deleting data in SD CARD from a given path directory


In BlackBerry we can delete all the data from a given path in SD card by using the following code method. it is help utility which we can use in our programs.

private static void deleteFolder(String fullPath) {
   try {
    FileConnection dirConn = (FileConnection)Connector.open(fullPath, Connector.READ_WRITE);
       if(dirConn.exists() && dirConn.isDirectory()) {
        for(Enumeration e = dirConn.list("*", true); e.hasMoreElements();) {
String name = e.nextElement().toString();
deleteIOneFile(fullPath + name);
}
        dirConn.delete();
       }
       dirConn.close();
} catch(IOException ioe) {
System.out.println("1 Exception : " + ioe.toString());
}
}

Where path can be like
 fullPath= "file:///SDCard/Databases/SQLite_Guide/imageshere/";

No comments:

Post a Comment