在代码中给文件设置权限(代码中执行linux命令)


	private void Chmod() {
		try {
			File f = new File("/data" + "");
			File f1 = new File("/data" + "");
			Log.v("daming.zou***f**", "" + f.getAbsolutePath());
			Log.v("daming.zou***f1**", "" + f1.getAbsolutePath());
			if (f.exists()) {

				Runtime runtime = Runtime.getRuntime();
				Process proc = runtime.exec("chmod 777 " + f.getAbsolutePath()
						+ "/");
				boolean issuccess = proc.waitFor() == 0;
				Log.v("proc**file1**", "" + issuccess);
			} else if (f1.exists()) {
				Runtime runtime = Runtime.getRuntime();
				Process proc = runtime.exec("chmod 777 " + f1.getAbsolutePath()
						+ "/");
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}




你可能感兴趣的:(在代码中给文件设置权限(代码中执行linux命令))