Hi all!
I want to read and write /data but when i try to acces, it says "permision denied" because i need root rights.
How can i do it ? Thanks and sorry for my bad english
Sent from my GT-S5830 using xda premium
JorX_AD said:
Hi all!
I want to read and write /data but when i try to acces, it says "permision denied" because i need root rights.
How can i do it ? Thanks and sorry for my bad english
Sent from my GT-S5830 using xda premium
Click to expand...
Click to collapse
Here you go: http://forum.xda-developers.com/showthread.php?t=2226664
Thanks to nikwen, There is a very easy way in which we use the RootTools library.
Here it is.
If you want to know if you have access to root or know if device is rooted, here's the code:
Code:
if (RootTools.isRootAvailable() && RootTools.IsAccessGiven()){
// So the device is rooted and you have access to Root.
} else {
// Either the device is not rooted or your app doesn't have access to Root.
}
Also don't forget to include SuperUser permission in your manifest.xml
Code:
<permission name=".ACCESS_SUPERUSER"/>
torpedo mohammadi said:
Thanks to nikwen, There is a very easy way in which we use the RootTools library.
Here it is.
If you want to know if you have access to root or know if device is rooted, here's the code:
Code:
if (RootTools.isRootAvailable() && RootTools.IsAccessGiven()){
// So the device is rooted and you have access to Root.
} else {
// Either the device is not rooted or your app doesn't have access to Root.
}
Also don't forget to include SuperUser permission in your manifest.xml
Code:
<permission name=".ACCESS_SUPERUSER"/>
Click to expand...
Click to collapse
The best RootTools tutorial can in my opinion be found on the wiki page of the project: https://code.google.com/p/roottools/wiki/Usage
I really recommend RootTools as it is MUCH easier than doing everything on your own, especially if your app needs SU access more than once.
Related
For clarification...
An app has to request root permissions to run as root, you cannot just give it the permissions? Is there a setuid? The "/system" filesystem is ext3 on this phone. "ext3" supports setuid & setgid, are these supported by Android?
In other words, is there any way to give a non-root app root permissions?
nodots said:
For clarification...
An app has to request root permissions to run as root, you cannot just give it the permissions? Is there a setuid? The "/system" filesystem is ext3 on this phone. "ext3" supports setuid & setgid, are these supported by Android?
In other words, is there any way to give a non-root app root permissions?
Click to expand...
Click to collapse
have you "rooted" your bravo using super one click etc?
the su built for rooted android phones has a hook to the superuser.apk so that any app requesting root must be approved by the user. You can set the app to a whitelisted app so it always gets root permissions, so that is what i recommend. this is a much important security feature and i highly recommend you dont circumvent it. that being said, there is a su out there that doesnt require approval and just gives approval so you can find it on xda if you want it but really its not a good idea or recommended
I have a related question: How do pre-installed apps on unrooted phones get root permission? I would expect that there are some that do, although I cannot give any examples.
how to fix This { install blocked for security reason
for security your phone is set to block installation of applications not obtained from Android market
} and need add Arabic Language in my nook
this message show at when?????
You have to enable the option "Unknown sources: Allow installation of non-Market apps".
On most Android devices, this option appears in the Settings, but not on the stock Nook.
You can install a replacement Settings.apk (a bit tricky)
You can use various tools that will reset this option.
If you have root and adb then you can install sqlite3 for Windows on your desktop and do this:
Code:
adb pull /data/data/com.android.providers.settings/databases/settings.db settings.db
sqlite3 settings.db
update secure set value=1 where name='install_non_market_apps';
.q
adb push settings.db /data/data/com.android.providers.settings/databases/settings.db
speedman2202 said:
this message show at when?????
Click to expand...
Click to collapse
lma bnzl mlf mn no3 .abk 3ly krt elmomry btigy hazhy el rsala
ahmedelbeah said:
lma bnzl mlf mn no3 .abk 3ly krt elmomry btigy hazhy el rsala
Click to expand...
Click to collapse
ok . from ur nook appz . search for nook color tools and open then check on install from non market appz
then try install what u want ....... if u cant understand me well . PM
good luck
Sent from my NOOK using xda app-developers app
speedman2202 said:
ok . from ur nook appz . search for nook color tools and open then check on install from non market appz
then try install what u want ....... if u cant understand me well . PM
good luck
Sent from my NOOK using xda app-developers app
Click to expand...
Click to collapse
done now thanx Renate NST and speedman2202
Hey guys i am brand new in android app develop I want to create a app just simply copy two file to root I want to know how could I start it?
I am computer science major so i know Java, C , C# and other language . But I think java is most easy way to do it ! Anyway I hope to get help to start my project ! Thanks:victory:
You have to use busybox
Like this
su (for superuser permissions)
busybox mv path path
You have to execute this commands from your app
Sent from my GT-S5570 using XDA Premium 4 mobile app
Hi,
I'm writing an android application which have to run a android shell script as root. But I don't know how to do that . Can anyone help me?
It's a very simple application with a button in the middle of the screen and if I press that button the script should be executed as root. :good:
Use
Process p = Runtime.getRuntime().exec("su");
p.getOutputStream().write("your command".getBytes());
EmptinessFiller said:
Use
Process p = Runtime.getRuntime().exec("su");
p.getOutputStream().write("your command".getBytes());
Click to expand...
Click to collapse
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
supergerrit said:
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
Click to expand...
Click to collapse
You can use superuser libraries like libSuperuser by chainfire, or RootTools by stericsson to execute the script which can handle the output for you. You can assign the output to a String and then display it in a dialogbox.
See these links -
How to SU
RootTools
supergerrit said:
Thank you for tour reply, :good:
I have one more question. How can i show the output of the script to the user in something like a popup message?
Click to expand...
Click to collapse
You would need
say if your prcess is Process p
Scanner s = new Scanner(p.getInputStream)
while(s.hasNextLine){
//s.nextLine() will give the process output
}
Sent from my GT-S5302 using Tapatalk 2
gh0stslayer said:
You can use superuser libraries like libSuperuser by chainfire, or RootTools by stericsson to execute the script which can handle the output for you. You can assign the output to a String and then display it in a dialogbox.
See these links -
How to SU
RootTools
Click to expand...
Click to collapse
Thank you so much for your reply. The links helped me so much! :good:
But i have one more question:
Can i also run multi line shell schripts from a file in the assets folder?
Example: i have a file: 'scripfile'. I put this one in the assets folder of the application. How can i run that file?
supergerrit said:
Thank you so much for your reply. The links helped me so much! :good:
But i have one more question:
Can i also run multi line shell schripts from a file in the assets folder?
Example: i have a file: 'scripfile'. I put this one in the assets folder of the application. How can i run that file?
Click to expand...
Click to collapse
I can think of one way to do it. Like sak-venom1997 posted above, you can read the file one line at a time and save it to a String array or a list and pass the String array to the superuser library
PHP:
List<String> Shell.SH.run(List<String> commands)
or
List<String> Shell.SH.run(String[] commands)
Will it work for non rooted devices??
sak-venom1997 said:
You would need
say if your prcess is Process p
Scanner s = new Scanner(p.getInputStream)
while(s.hasNextLine){
//s.nextLine() will give the process output
}
Sent from my GT-S5302 using Tapatalk 2
Click to expand...
Click to collapse
Will the codes be applicable for non rooted device? or it will run on all the devices..?
If it is for non rooted... then can you please suggest me how can I access shell.. or run shell commands without rooting the device.
nitinsao said:
Will the codes be applicable for non rooted device? or it will run on all the devices..?
If it is for non rooted... then can you please suggest me how can I access shell.. or run shell commands without rooting the device.
Click to expand...
Click to collapse
If you take a look here
http://su.chainfire.eu/#how-call
you will notice this-
PHP:
List<String> Shell.SH.run(String command)
which I believe can be used for executing shell without root. Now I haven't tried it, so I am not sure, but it's worth a shot.
I just need help at best way for me to build a simple app to request for root, then dd install a kernel
dd if=boot.img of=/dev/block/mmcblk0p14
and then give option to reboot.
Thanks for any advice
carl1961 said:
I just need help at best way for me to build a simple app to request for root, then dd install a kernel
dd if=boot.img of=/dev/block/mmcblk0p14
and then give option to reboot.
Thanks for any advice
Click to expand...
Click to collapse
Just a tip, I'm assuming this app will work only for your device or similar partitioned devices. You could read the mounts file under proc using java and extract the Mount path instead of hard coding it. And executing shell commands can be done using JNI system() calls or from java it's Runtime.getRuntime().exec(ddcommandhere);
MasterAwesome said:
Just a tip, I'm assuming this app will work only for your device or similar partitioned devices. You could read the mounts file under proc using java and extract the Mount path instead of hard coding it. And executing shell commands can be done using JNI system() calls or from java it's Runtime.getRuntime().exec(ddcommandhere);
Click to expand...
Click to collapse
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
carl1961 said:
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
Click to expand...
Click to collapse
Well, let android studio create a project for you, you'll have an activity there run your code from there on another thread that's not the main ui thread.
carl1961 said:
thanks for the advice, my issue right know is still l amd still learning android studio. I cannot figure out how and where to use this command. all apk guides I find is for like online and hello world LOL
Click to expand...
Click to collapse
perhaps you can just use a button in your MainActivity
And override the onClickListener
Then put that command(RunTime.getRunTime().exec().. in that method. Easy
Sent from my A0001 using Tapatalk 2
Vivek_Neel said:
perhaps you can just use a button in your MainActivity
And override the onClickListener
Then put that command(RunTime.getRunTime().exec().. in that method. Easy
Sent from my A0001 using Tapatalk 2
Click to expand...
Click to collapse
Thanks @Vivek_Neel, might get time this weekend to try that