Android Utililty Methods Path Create

List of utility methods to do Path Create

Description

The list of methods to do Path Create are organized into topic(s).

Method

StringgetDownloadPath()
Gets default directory(path) for downloaded files
return System.getProperty("user.home") + "\\Downloads\\";
StringgetFilePath(String path)
get File Path
String result = null;
if (StringUtil.isNotEmpty(path)) {
    int num = path.lastIndexOf("/");
    int tnum = path.lastIndexOf("\\");
    if (tnum > num)
        num = tnum;
    if (num > 0)
        return path.substring(0, num + 1);
...
StringgetPath(String fullFileName)
get Path
int pos = fullFileName.lastIndexOf("/");
if (pos == -1) {
    pos = fullFileName.lastIndexOf("\\");
String shortFileName = fullFileName.substring(0, pos);
if (StringUtils.isEmpty(shortFileName)) {
    return "/";
return shortFileName;
StringgetProjectAbsolutePath()
get Project Absolute Path
return new java.io.File("").getAbsolutePath();
StringgetUniqueFilePath(String filePath)
get the unique file path by add a serial number.
int id = 1;
File file = new File(filePath);
while (file.exists()) {
    if (file.isDirectory()) {
        if (id == 1)
            filePath += "[" + (id++) + "]";
        else
            filePath = filePath.substring(0,
...
StringgetFolderPathNameYearAndMonthSubDirectoryDay()
get Folder Path Name Year And Month Sub Directory Day
String path = "";
Calendar cal = Calendar.getInstance();
path += String.valueOf(cal.get(Calendar.YEAR)) + "_";
path += String.valueOf(cal.get(Calendar.MONTH) + 1);
path += System.getProperties().getProperty("file.separator");
path += String.valueOf(cal.get(Calendar.DATE));
return path;
StringgetNameDelLastPath(String fileName)
get Name Del Last Path
int point = getPathLastIndex(fileName);
if (point == -1) {
    return fileName;
} else {
    return fileName.substring(0, point);
StringgetPath(String path, String parent)
get Path
if (path.charAt(0) != separator
        || (path.length() > 1 && path.charAt(1) == ':' && separator == '\\')) {
    return parent + separator + path;
} else {
    return path;
StringgetRealPath(String name)
Get real path.
String senHome = System.getProperty("sen.home");
if (senHome == null) {
    return name;
} else {
    return senHome + File.separatorChar + name;
StringgetFullPath(String inBaseUrl, String inUrl)
get Full Path
String path = makeUrl(inBaseUrl, inUrl);
if (path == null || path.length() == 0) {
    return null;
if (path.startsWith("/")) {
    path = F_FILE_SCHEMA + path;
return path;
...