Code example for Random

Methods: nextInt

0
     * @param location This is path where the file is to be created 
     *            "/sdcard/Output/" 
     * @return Path in form of /sdcard/Output/200910100000 
     */ 
    public String createRandomFile(String location) {
        Random randomGenerator = new Random();
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssS");
        Date date = new Date();
        final String filePath = location + dateFormat.format(date) +
            randomGenerator.nextInt(10);
        Log.i(TAG, ">>>>>>>>>>>>>>>>createRandomFile  Location= " + location +
            "\t FilePath = " + filePath);
        return filePath;
    } 
 
    /** 
     * This method recursively deletes all the file and directory 
     * 
     * @param directory where the files are located Example = "/sdcard/Input" 
     * @return boolean True if deletion is successful else False 
     */