Enabling root permissions/functioanlities from the Android application or a folder in Android filesystem with default Permission

198 views
Skip to first unread message

s.rawat

unread,
Jul 26, 2011, 4:39:36 AM7/26/11
to android-d...@googlegroups.com, android...@googlegroups.com, andro...@googlegroups.com
 
HI all Again,
I am makaing an application which performs the memory(file read write edit modify) and cpu(executing comples alogortihms of mathematics) opeartions also similiarly I am doing the I/O operations on the device memory(file write read on sqlite DB).I want the root permission for copyingm certain files on the memory and IO (test files) for that I am doing push commands at the adb shell and doing chmod to a particular directory (/data)  where Iam copying the tets files.This is happening in root mode only , so I am doign this for two pruporses :
 
(1) Enabling the read write permission on the device memory and for IO operation
(2) for producing the log files at the end which will get copied on the device memory.
 
But for this I Have to manually to it on the shell.To automate it I ahve written a script and trying to run it from the application level but since it is running under application(user level context) I am not able to enable to do it as I am not doing it on the shell as a root 9 as I was doing it manually earlier).How do i get arround with it?How can i do it frmo the application level?Or doing manually at the shell prompt is the only way I can do it.I want it to automate so that user doesnt have to do this and he simply run the android application which internally does this opeartions(more root like operations, chmod, copying test file etc)
 
here is my script :

chmod 777 /data

adb push /my/workspace/myproject/jni/mymodule/data/myfolderonPC/mytestfile1 /data/myfolderonDevice/
adb push /my/workspace/myproject/jni/mymodule/data/myfolderonPC/mytestfile2 /data/myfolderonDevice/
adb push /my/workspace/myproject/jni/mymodule/data/myfolderonPC/mytestfile3 /data/myfolderonDevice/
adb push /my/workspace/myproject/jni/mymodule/data/myfolderonPC/mytestfile4 /data/myfolderonDevice/
adb push /my/workspace/myproject/jni/mymodule/data/myfolderonPC/mytestfile5 /data/myfolderonDevice/

 

 
I need above steps to be automated by the application wihtout doing it manually.
 
Other way round for this problem is --> Is there any folder in the android file system where i could create a database(sqlite) and do the file operation(read write ) in this case I dont have to enable the chmod permission .
 
 
 
Plz assit, help, groan..
 
Rgds and Thanks in advance,
Saurabh

 

"..pain is temporary.....quitting lasts forever......"

Chris Stratton

unread,
Jul 26, 2011, 1:16:54 PM7/26/11
to andro...@googlegroups.com, android-d...@googlegroups.com, android...@googlegroups.com
On Tuesday, July 26, 2011 4:39:36 AM UTC-4, Jessica wrote:
Other way round for this problem is --> Is there any folder in the android file system where i could create a database(sqlite) and do the file operation(read write ) in this case I dont have to enable the chmod permission .

Yes, android provides an internal storage directory for applications and also a related place for them to create sqlite databases.

At the java level, finding the appropriate path is handled automatically by some of the typical functions, but you can determine it with Context.getDir() and Context.getFileDir() - if you want to do something in the NDK, probably call one of those from java and pass the result to your ndk routines as a java string, where you would convert it to a native string for the posix file functions.

Using root access is to be avoided as it's not available on unmodified devices, and should cause some due suspicion ("why does this app need that?") on the part of the user even where it is.  It's also entirely outside the scope of the ndk list.

s.rawat

unread,
Jul 28, 2011, 2:11:45 AM7/28/11
to andro...@googlegroups.com, cs0...@gmail.com, android-d...@googlegroups.com, android...@googlegroups.com
Hi Chris ,
Thanks for the reply it worked pretty well.
The /data folder in the android file system has the default application folder where the application specific read write happens
they generally looks like this :
"/data/data/my.package.name/<app_my custom folder>/
    directory=getDir("fodlername", Context.MODE_WORLD_WRITEABLE | Context.MODE_WORLD_READABLE); 
 
and this directory has been used to do the file ops.
 
Also if I want to the same in the SD card is there any way to gain the permission and then do it on that.ideally once the permission is gained we can do the normal file operation just like i did above for the android file system
 
Thanks ,
Rgds,
saurabh
 

"..pain is temporary.....quitting lasts forever......"



--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/android-ndk/-/IdiVQai6JIcJ.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.

mic _

unread,
Jul 28, 2011, 3:29:55 AM7/28/11
to andro...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages