我做了這個劇本,但不工作:Drop_caches通過應用程序無法正常工作
package com.mkyong.android;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
import java.io.IOException;
import com.example.toast.R;
public class MainActivity extends Activity {
private Button button;
public void onCreate(Bundle savedInstanceState) {
final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("su");
}
catch (IOException e) {
e.printStackTrace();
}
super.onCreate(savedInstanceState);
setContentView(R.layout.tab1);
button = (Button) findViewById(R.id.button1);
button.setOnClickListener(new OnClickListener() {
@SuppressLint("SdCardPath")
@Override
public void onClick(View arg0) {
final Runtime runtime = Runtime.getRuntime();
try {
runtime.exec("echo 3 > /proc/sys/vm/drop_caches");
Toast.makeText(MainActivity.this, "Script lanciato con `successo, memoria svuotata.", Toast.LENGTH_LONG).show();`
}
catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
不會釋放RAM內存:(而是通過終端模擬器goes..If我試圖改變指揮例如,做一個目錄與MKDIR去,去一個文件TXT,甚至寫作..有什麼錯?
你的意思的問題基本上是我的殼是firt(SU)後?所以我的過程不走?我的天哪我找不到出路:(。但爲什麼其他命令(mkdir等)去,這不是?這是不可思議的! – Davidebj 2013-04-10 12:26:44
我試着再次改變和寫:runtime.exec( 「su -c /free.sh」);但是沒有......我也嘗試過runtime.exec(「su -c'/free.sh'」);沒有任何東西......我也嘗試過runtime.exec (「su -c echo 3> XXX」);但沒有任何變化!!!!!! wtf太難了!我嘗試了所有的東西! – Davidebj 2013-04-10 14:00:20
當你說任何東西時,你的意思是內核沒有刪除所有的文件緩存?通過在您的adb外殼上執行此操作,確保它可以在您的設備上正常工作嗎? – Robin 2013-04-11 02:36:33