1

I am creating an android application, and I want to directly access another application's database file (read from it). What's the best way to go about this, since applications are sandboxed from each other. I am okay with making the app require root permisisions, I am just unsure as to what the best way to do this is.

Should I make a copy of the database to my app's local area using the su command every time I start, and then use that database? Or should I directly access the database?

Stewbob
  • 16,759
  • 9
  • 63
  • 107
xur17
  • 506
  • 1
  • 8
  • 24

1 Answers1

3

Are you developing both apps? If so then the the correct way to do this is to make use of ContentProviders If you aren't developing the app with the database check with its developer to see if it provides a ContentProvider.

If the app with the database you are trying to access doesn't provide an easy way to access its data then you can't do this without root, at which point you're problem has become many times more difficult.

slayton
  • 20,123
  • 10
  • 60
  • 89
  • Unfortunately I not developing both apps. To be more specific, I am trying to use the database included with the Google Voice app that has the number mappings used for directly calling or texting a number through Google Voice. – xur17 Apr 06 '12 at 16:36
  • According to [this](http://www.stealthcopter.com/blog/2010/01/android-requesting-root-access-in-your-app/), I need to use the command "Process p = Runtime.getRuntime().exec("su");", but I am assuming that only escalates my permissions for running commands in the shell, in which case I would most likely have to copy the file when the application starts. Is there any way to directly access the file? – xur17 Apr 06 '12 at 16:37