Java tutorial
//package com.java2s; import android.util.Log; import java.io.File; public class Main { private static final String FS = File.separator, ID = "Helper"; public static String getParentPath(String path) { if (!path.contains(FS)) { return FS; } if (path.lastIndexOf(FS) < 2) { return FS; } String pass1 = path.substring(0, path.lastIndexOf(FS)); pass1 = pass1.substring(0, pass1.lastIndexOf(FS)); Log.i(ID, "getParentPath: " + path + " -> " + pass1); return pass1; } }