AbhiRocks
unread,Aug 22, 2011, 3:23:19 AM8/22/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to android-platform
Hi all,
I am trying to create an apk which would execute a shell command.
This shell command will write to a file in the shell i.e. sdcard.
The code snippet that i am using is this:
@Override
protected void onStart() {
super.onStart();
Handler handler1 = new Handler();
handler1.postDelayed(new Runnable() {
public void run() {
String cmd = "ls /data >> /sdcard/date.txt";
java.lang.Process p;
try {
p = Runtime.getRuntime().exec(cmd);
BufferedReader input = new BufferedReader(new
InputStreamReader(p.getInputStream()),cmd.length());
Log.i("AbhiRocks", "Output is " + input.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
}, 5000);
}
And in the manifest.xml file i have added the line:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
But i am unable to generate any date.txt file once i run this apk.
P.S. It executes other shell commands which does not involve writing
to a file.
I know that we can write to a file using inbuilt android apk
commands but I need to write/create a file using
shell commands only.
Thanks and Regards,
AbhiRocks