Return owning UID of given path, otherwise -1 - Android android.system

Android examples for android.system:Os

Description

Return owning UID of given path, otherwise -1

Demo Code

import android.annotation.NonNull;
import android.provider.DocumentsContract;
import android.system.ErrnoException;
import android.system.Os;


public class Main{

    /**//www .j  a va2s . co  m
     * Return owning UID of given path, otherwise -1.
     */
    public static int getUid(String path) {
        try {
            return Os.stat(path).st_uid;
        } catch (ErrnoException e) {
            return -1;
        }
    }

}

Related Tutorials