안드로이드 CPU Core 개수 구하기


MainActivity.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    //CPU 코어갯수
    public String getCpuCores(){
        File dir = new File("/sys/devices/system/cpu/");
        //CPU 코어 파일목록
        File []files = dir.listFiles(new FileFilter() {
            @Override
            public boolean accept(File pathname) {
                if(Pattern.matches("cpu[0-9]", pathname.getName())){
                    return true;
                }
                return false;
            }
        });
 
        //CPU Core 개수
        return files.length+"개";
    }
cs



결과


+ Recent posts