File rootDir = Environment.getRootDirectory(); String rootDirPath = rootDir.getAbsolutePath(); Log.d("Root Directory", rootDirPath);
File rootDir = Environment.getRootDirectory(); if (rootDir.canWrite()) { Log.d("Root Directory", "Can Write"); } else { Log.d("Root Directory", "Cannot Write"); }This example gets the root directory of the device and checks if it is writable. If it is writable, "Can Write" will be logged, otherwise "Cannot Write" will be logged. Package Library: The package library for the Environment class is "android.os".