Cannot find location of SQLite database file on Galaxy Nexus - android

I opened a SQLite database in my project. To see if the db was actually created I went to Data/Data to find the package name... not there. While testing I would like the ability to delet the file.
So I added data to the db, then read it out. This works fine, but still no file at either /Data/Data, or at /Android/Data/Data. Is the file hidden? Other dowloaded aps have data at /Data/Data/package/... but not the one I wrote. It does exist - I can read and write to/from it, but cannot find it.
//data/data/Your-Application-Package-Name/databases/your-database-name NOT THERE
Using a Samsung Galaxy Nexus for testing, not the emulator. The Nexus does not have external SD memory card.
SQLite databases are only accessible to the creating project, but is there a tool that can access it externally? I have sqlitebrowser (awsome) i will try if I can find the file.
I would try to Root the Nexus, but I can already see /Data/Data/ other items/Data/their data, so hopefully I do not have to go that route.

You're not able to access any contents of /data/data if you access it from adb shell without first rooting the device. Shell is considered as another app (more precisely another linux user), so it's prevented from accessing other app's data in /data/data.
Root the device or use emulator to see the data.
Personally I really recommend rooting the device for development.

Related

Location of my package while USB debugging in eclipse

I searched a lot in DDMS all folders but can not find the location of my package folder in file manager. I have search it into the storage/sdcard0 but there also my package is not present.
take a look I uploaded photo. Is there any special setting from mobile ?
My phone android version 4.4.2
please help me to find.
UPDATE
I gone through this steps.
And I reach to My database folder .Now What to do.
adb shell
run-as com.mypackage
ls
cd databases
ls
Now After this what to do.
As you are looking for the database.
I used to copy the database file to any other location after updating it. ( in my code)
Then I use any sqlite viewer over phone or over PC to view it.
I Think you need a rooted device
as far as I know the files on sdcard/Android/data are not the primary files for the packages, those are only extra files (most probably not critical and large files) which are saved on the external storage which is the sdcard.
main package files are saved on the internal storage.
I think you can try this link
http://developer.android.com/guide/topics/data/install-location.html
you can change the location of app installation.
Br,
You can't see the files in DDMS, but you can get a list of the location of all the files using the command:
adb shell pm list packages -f
(you can also add an optional extra parameter to restrict the files listed to be those that match your extra parameter).
Once you have the location of the file, you can then issue a command like
adb pull /system/app/GoogleEarth.apk
to actually get the file off the device and on to your PC.
None of this requires a rooted device.
Since you're looking for the database of your application: Unfortunately there's no way to access the /data/data/your.package.name/databases through DDMS on an unrooted device, as Hussein Ali pointed out correctly. (By the way: The app-data (shared prefs, databases) will reside there no matter of the install-location)
Something like this won't work neither because of Permission denied.
adb pull /data/data/your.package.name/databases/db.sl3
Luckily ICS (Android 4.0) introducted the ability to backup your application-data. That's a possible way to copy your database from your unrooted device to your PC. Please see this post on StackOverflow in order to see what you need to do.
copy the database file to your SD card so you'll be able to use adb pull and get the database to your PC (You can't pull files from private folders such as /data/data/...).
I recommend using SQLite Expert to browse the DB on your desktop:
http://www.sqliteexpert.com/
Also, If you still want to use sqlite3 on your device, check out this answer: https://stackoverflow.com/a/7878236/624109
phone storage is treated as external storage in location "sdcard" where you havn't saved anything so nothing(package named folder) is created... your package will be in app's "private storage" that's in root "data/data/pkg_name" folder accessible only on rooted device.

Accessing Android Files and Database Directly on the device if rooted?

When developing for Android I prefer just working with a real device plugged in most of the time since the Android emulators are such total garbage. The one pain point is when I want to access files and sqlite databases though. I believe with the adb shell it is possible to pull the database across, but this isn't a very convenient process.
I'm wondering if there are any tools on the market that allow you to see the database in real time, even if it requires rooting a device I'm open to it.
I am afraid that there are no tools that will let you see the db real time. You will need to get the db from the device and the see it on your system. You will have to root the phone and get SuperUser permission to access app databases. The database will (after getting root) then be available in the /data/data/com.your.application/databases folder.
Hi You don't have any tools to see the database in real times. But its achievable in rooted device. If your device is rooted just install root explorer app in it. and then browse for your package name in data/data/ location. There you will find out all the internal memory files including database files. hope this helps you.

Accessing application Databases on my Android device(LG Optimus one p500)

I have created an android application for my Android device which stores records into sqlite databases and even the retrieval of the data from the database works correctly on my application. Now i want to access the database file located in the location as follows:
/data/data/org.project.compdroid.dash1/databases/data
where data is my database file.
This data file i want to export to my pc to keep a backup of all the records.
for this I first tried accessing it from the emulator by the command
adb pull /data/data/org.project.compdroid.dash1/databases/data [local address path]
this worked correctly for the emulator. but when i try to copy the same file from my Android phone it says permission denied. I think since I am not the root user for my phone I am not allowed to access it and I am allowed to achieve it in my emulator since I am already rooted there.
Now is there a way by which i will be able to copy the data file from my android phone without rooting it? or is rooting the only solution for my problem?
Please do suggest any other technique(if there are any) for copying the database files from an android phone to my computer.
Thanks in advance...
You can include code in your app that will copy the file from internal storage onto the sd card, since your App has full access to its own storage. See How to backup database to SD and Backing up your Android..
You could also spit out the Db as a text file which can then be imported into any DB.

Android SQLite path

I am working with SQLite in an App. It writes to the database, etc., with no problem. However, I can not find this new database. I have tried changing the directory with cd /data/data/packageName/databases, but it says "no such file or directory". Also, this database is not found when I click on the File Explorer in eclipse. My logging tells me the database was created and that it is being written to. I think I need to set the path in the shell or something to that effect using adb, but I have no idea how to do that. Can anyone give me some instruction? Also, I am using my phone for development. The database also does not show up when using the emulator.
Thanks very much.
Matt
Matt,
This thread gives a good explanation on why you might not be able to access the data folder on your phone.
Can't access data folder in the File Explorer of DDMS using a Nexus One!
You can still test the Sqlite code though. Just boot up an emulator. The emulator will have no access restrictions. Once it's booted up you can use the ddms tool (located in the tools directory under your android SDK install folder). It has a File Explorer and you can download the files from the /data folder.
Also, I am using my phone for development.
You cannot access the database on a standard Android device except via your own application code.
Your options are:
Do this sort of testing on an emulator, in which case you can access the directory that you are failing to access on the device
Add a database backup feature to your app, that copies the (closed) database to external storage, so you can examine it
Root your phone (leastways, I am under the impression this can help get you to this directory -- haven't done it myself)
The database also does not show up when using the emulator.
Try harder. If you can store data in the database and read data out of it using SQLiteDatabase, then the database file is there.

Reading database file from android device

I've been trying to pull a copy of my sqlite database from my android app for dev. My first attempt was to call:
./adb shell
cd data/data
cd com.example.app
cd databases
But then I get stuck here as I do not have permission to do a pull or even view the files in that dir!
So I thought I'd try out the DDMS File Explorer which gives me this:
But when I try and pull files from here (I would expect them to be in the data folder) it just pulls the directory and nothing else. How can I do this to pull a copy of the database my app is creating/using?
I have tried this when the phone is on the SD card and on phone memory. I guess I could copy to SD card and then plug the SD card to pc rather than the phone and do it that way? Not sure if it would work and would be rather annoying to dev like that!
Thanks
If your device does not give you access to this directory (and your device is not rooted -- if you become root, you'll have access), you will need assistance from your application.
The application can, for example, copy databases/your_database_name.db to a readable location, perhaps on the SD card. Then you can pull from there.
IF you just need the DB for general checking/viewing you can run your app on the emulator and get the DB from there. If you need the specific instance on your device you need to root your device as others are suggesting.

Categories

Resources