I am working on a test of an Android application that runs the SQLite methods in the Android API. I would like to get code coverage of the SQLite code in the Android Open Source Project (AOSP), and I have it set up to run G-Cov and save that coverage information when I run my test. However, I have no idea where this coverage information is stored. I assumed it would be in data/data/package-name, but I don't see anything, and I couldn't successfully pull all of my files off of the Android emulator.
Does anyone know where this file will be stored? I'm not sure if it is stored with SQLite or on the emulator (which is where I assume, as I did not see it in the SQLite directory).
Thanks.
EDIT: Specifically, I am looking for *.gcno and *.gcda files.
EDIT: Now I'm thinking they have to be on a shared library on the emulator, although in File Explorer (I am using Eclipse Juno with ADT), I see nothing close to /lib/* and /data/data/package-name/lib is empty. Anyone know where that location could be?
is in data/data/ nothing?
when this folder is empty, maybe try sqlite manager for eclipse
Related
So it seems that when I run my app on my phone / a phone emulator that the database file is not ending up in the correct directory over there. It seems that the app is looking for it in data/data/com.mobiletextadventure/databases. It doesn't find it there and then creates a new empty database in that directory as far as I can tell and uses that.
If I manually copy the database file to data/data/com.mobiletextadventure/databases after I have already installed the app and then run it, it picks up the database and doesn't create a fresh empty one. This is what I want obviously, but I need it to do this on initial install rather than having to manually copy it across after installing.
In my project in android studio the database is in android/assets/ folder. How do I find out where exactly this database is being copied to my phone / emulator? It's clearly not going into data/data/com.mobiletextadventure/databases, but if I can get it to install into there then my app will work fine without any manual intervention.
Another way of asking this question might be... when an app is installed to phone/emulator, what exactly happens to the files in /android/assets? Where are they copied to on the phone/emulator and why?
How do I find out where exactly this database is being copied to my phone / emulator?
It is not getting copied anywhere, unless you do the copying.
when an app is installed to phone/emulator, what exactly happens to the files in /android/assets?
Absolutely nothing. They are part of the APK. You can obtain an InputStream on an asset via AssetManager (see getAssets() on Context).
If you are seeking to package a database as an asset and use it, you can see how SQLiteAssetHelper does that.
In the end I was able to achieve it by following this post:
https://blog.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applications/
I initially got an uknown error code 14 after implementing it but all I had to do was replace the checkDataBase() code with the code below and it worked perfectly:
File dbFile = myContext.getDatabasePath(DB_NAME);
return dbFile.exists();
I am trying out a test application on an Android emulator. I would like the app to write data to a file that is stored on my C drive. I have read and written data off Samba drives and webservices, but reading and writing to my local hard seems to be a puzzle. I tried filePath = "file:///C:/test/input/"; to point it as my parent folder, but the Emulator doesn't seem to recognize the directory, and I get a 'not found' error.
Any ideas will be appreciated. Thanks.
I would like the app to write data to a file that is stored on my C drive.
That is not possible, unless that file is accessible via some server. The Android SDK emulator does not have access to the filesystem of the developer PC.
Given that you are using an android emulator I am guessing it is setting up some special folder to act as a proxy for the androids hard drive. Meaning that the android emulator doesn't understand what your C drive is and instead is looking in it's 'hard drive' for a file. Find out where the emulator puts files for android, it could be a temp folder, and store your file there.
Edit: Where is Android Emulator Internal Storage this question should help you find where the files should be stored and the naming conventions.
If you don't care using genymotion emulator instead you can refer to this answer, pointing to this post, it has just what you need
So i have been looking for this answer for the past 2 days. all of them want to know how to extract the database file .sql from the device your testing your app on. What i want to do is use a manager, like fire fox's sqlite manager, to open the location of the file and view the data base as information is being entered. I did this once when i was using titanium, but now have switched to eclipse. So what i want is, when i am running my virtual machine, android emulator, i want to fine the location that it is reading the sql file from. doing this i can open it with my fire fox manager and as info is going into the file the manager will show me whats going in and out. Basically i want to see real time info from my internal database, either from emulator or phone. PLEASE HELP!
Go to this link and get the SQLiteManager plugin for eclipse.
I implemented my first app using Xamarin Studio (Mono for Android). This app stores some data in a SQLite db, which works fine on a Sony Tablet S device.
My question is: is there a way to get db file and see, for example, its size?
I looked up to the following path
/data/data/My-Application-Package-Name/databases/My-database-name
but it doesn't seem to exist.
Thanks for any help!
You can use Eclipse to go right to it using the sqlite manager plug-in (http://www.coderzheaven.com/2011/04/18/sqlitemanager-plugin-for-eclipse/)
Download the *.jar file from the website I reference above to the
"dropins" folder in eclipse (open your eclipse folder and you should
see it)
Then restart eclipse and go to the DDMS. You may have to do
windows->views-ddms if it isn't already being displayed...
Select your device from the left panel then use the file explorer to go to your data
directory/YOURAPP/databases. Hopefully there will be an icon that
shows up when you select your database. If not, rename your database to use the "db" ext.
Click it and it should open in the manager tab.
This is a valid database location (//data/data/My-Application-Package-Name/databases/My-database-name), but you can access it from file managers if you have root access only.
Look how it can be done here. Otherwise, if you want to get some info trough the code, you're doing something wrong, so publish the code and logcat.
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.