public static boolean clearAppUserData( String packageName )
{
boolean clearStatus = false;
DataOutputStream os = null;
DataInputStream is = null;
Process p = null;
try
{
p = Runtime.getRuntime( ).exec( "su" );
os = new DataOutputStream( p.getOutputStream( ) );
is = new DataInputStream( p.getInputStream( ) );
os.writeBytes( "pm clear " + packageName + " \n" );
os.flush( );
os.writeBytes( "echo test \n" );// 回显test 并获得test,确保上面的代码已经执行
os.flush( );
String result = is.readLine( );
Log.i( "clearData", result );
if ( result.equals( "test" ) )
{
clearStatus = true;
}
os.writeBytes( "exit\n" );
os.flush( );
os.close( );
p.destroy( );
}
catch ( IOException e )
{
e.printStackTrace( );
}
return clearStatus;
}
android清除应用缓存数据
最新推荐文章于 2024-07-25 19:24:53 发布