get Class Path from Class<?> - Android java.lang

Android examples for java.lang:Class

Description

get Class Path from Class<?>

Demo Code


public class Main{

    public static final String getClassPath(Class<?> value) {
        if (value == null) {
            return null;
        }//  ww w  . j a v a  2  s.  c om
        char[] temp = value.getName().toCharArray();
        for (int i = value.getPackage() == null ? 0 : value.getPackage()
                .getName().length() + 1; i < temp.length; i++) {
            if (temp[i] == '.') {
                temp[i] = '$';
            }
        }

        return new String(temp);
    }

}

Related Tutorials