Using root to access and modify a secure database on Android

I am trying to create an application that can access and modify a secured database in /data/data/

. This process obviously requires root privileges and I am testing this on a rooted device. The generic code for accessing the SQLite database is complete and works against a test database located elsewhere (at /sdcard/

).

However, when I want the application to access the database in /data/data/

, it clearly fails as I am trying to access it as a normal user. I've already read about the use of binary su

on Android currently, and as far as I understand it is usually used to execute shell commands only.

So, my initial idea to make this work was to simply change the file's permissions on application startup and change it on shutdown. So before actually trying to implement this in the application itself, I used my file explorer to change the resolution to rw-rw-rw-

. However, my application still couldn't open the database.

My next idea was to use the program sqlite3

directly from the shell, but I found out that my ROM doesn't come with it, so I'll have to redistribute it myself (Titanium Backup seems to do it).

However, there is something that makes me wonder if there might be a better way: I am using Root Explorer as my file explorer and it has a built-in way to view any SQLite database. Given that it doesn't seem to come with a custom sqlite3

binary, and that my phone doesn't have it itself, the access seems to be happening using regular Java tools. But how does the application get root?

Is there a way to make an Android application run as root? Or did I forget to set something for permissions earlier that prevented me from accessing it? Or does anyone know how Root Explorer does this?

+3


source to share


1 answer


You cannot elevate permissions to an already running process as far as I know. The simplest answer is to copy it somewhere using the root shell / command line, edit it, then copy it back as root. And yes, I read your question, just didn't explain the answer completely. Hope this is clear now. Not sure if root explorer is doing this or whatever, but it will work.



0


source







All Articles