• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Connect to the Droid's Database?

Can you explain some more what you are trying to do Merlin? You probably don't have access to another applications DB but there may be a way around this if you are trying to gain access to contacts or something?

Tom

How do I access an application's database? I've done some basic Android programming before, but never actually grabbed an existing database from a phone (in this case, the Droid). I'm very familiar with sqlite, just don't know where to get the database!
 
Upvote 0
I'm not sure what the options are with the Droid. I wanted to access the installed application's databases, not just the contacts.

Is there a list of all the databases somewhere accessible? If I install an app, there has to be a way to view the database info... Is this something I would need root access for?
 
Upvote 0
Hey Merlin try something like this to get all installed apps.

ArrayList<String> installedApps = new ArrayList<String>();

PackageManager applicationName = getPackageManager();
List<ApplicationInfo> applist = applicationName.getInstalledApplications(0);
Collections.sort(applist , new ApplicationInfo.DisplayNameComparator(applicationName));


for (int index=0; index< applist.size(); index++) {
ApplicationInfo info = applist.get(index);
getPackageManager().getApplicationLabel(info);
installedApps.add((String) getPackageManager().getApplicationLabel(info));
}
 
Upvote 0
You don't you create a SQLite DB in your own app space for your own application if you wish to uninstall apps or add contacts or any of that good stuff there is code to do it you don't interact with the DB's directly.

Describe what you are trying to do and I may be able to help more clearly as talking in riddles means it takes 10 times as long.
 
Upvote 0
I'm not sure how else to explain it.. I want to access the database of an installed application.

1. I install an application (such as one from the Android market)
2. I want to access the installed applications database

I'm not talking about my own application, I'm just talking about an installed application.
 
Upvote 0
Let's see if I understand what you're asking: There's an app installed on your phone which stores stuff in a database (all apps that use a database have their own database file under /data/data/<packagename>/...) . You would like to connect to that database and read/write the contents of it.

Since each app's files (including its database) are owned by that app/user, that means other users/apps can't access each other's DB without administrative/super privileges.

What you're looking for is a way to log in as a super user and access the sqlite databases used/owned by an app.

The adb (Android debugger tool that comes with the Android SDK) has what you're looking for:

Android Debug Bridge | Android Developers

If you haven't set up Eclipse with the Android SDK I think that's where you would want to start. Alternatively you could try and find a way to get to a root shell and then run sqlite from the command line and pass it the database file name that you want to access (see the example in the adb link above). You could then run SQL queries against the database of your choice.









I'm not sure how else to explain it.. I want to access the database of an installed application.

1. I install an application (such as one from the Android market)
2. I want to access the installed applications database

I'm not talking about my own application, I'm just talking about an installed application.
 
Upvote 0
That is exactly what I am trying to do. I already have Eclipse installed with the Android SDK. I've coded and installed my own programs before, but never done any database work.

From what it sounds like, it isn't possible to view the database for a program unless I was the one who originally wrote it (and that program was installed from my computer). Is that correct?

It does look like ADB provides shell access, so maybe my statement above is incorrect.

I haven't seen anything substantial on rooting the Droid yet, so that is not currently possible.

Thanks!
 
Upvote 0
There's lots of info for rooting on the developer101 sticky but I'm not a fan of rooting at this point. I just got my phone so I want to appreciate it for what it is before I try brain surgery on it.

The sample in the ADB article above shows a "#" prompt once the shell is opened, which suggests the adb shell is root/superuser and that you could access the databases owned by other apps. But when I opened a shell, I just had regular privileges and not access to the databases (I couldn't even get a directory listing of /data/data). Let me know if you get it working!
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones