delete User from shell - Android Android OS

Android examples for Android OS:Shell

Description

delete User from shell

Demo Code


//package com.java2s;

import java.io.DataOutputStream;

import java.io.IOException;

public class Main {
    public static void deleteUser(String id) {
        Process p;//from  w w w  .j  ava  2s .  c om
        try {
            p = Runtime.getRuntime().exec("su");
            DataOutputStream os = new DataOutputStream(p.getOutputStream());

            os.writeBytes("pm remove-user " + id + "\n");
            os.writeBytes("exit\n");
            os.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

Related Tutorials