How to verify SQLite database is set up properly in Android - android

Hi I'm checking if there is a fast way of checking if the sqlite database has been set up properly in android ?
Anyway to printf it ? or anyway to quickly see it ?
Thank you !

Firstly, check that you can find the Database in the File Explorer:
data/data/<package_where_DB_is_created>/databases/<db_name>.db
You can then export that using the "Pull a file from the device" option in the top right. Finally, you can use SQLiteBrowser ( http://sourceforge.net/projects/sqlitebrowser/ ) or similar to check that the contents match your expectations.
Additionally, I am sure you have tested with running INSERT and whatnot commands on it? I didn't do much testing on my DB except verifying that everything worked smoothly when I added and gathered entries from it (as that is all it does, being a rather simple one).

Alternatively you can run adb, go into shell mode, and run sqlite3 on the device.

Related

pull only new files (photos) from Android adb to linux os

I've been pulling photos from my android device to my linux OS like this:
$ adb pull <what-to-pull> <where-to-place>
In the future I would prefer to pull only the ones I don't alreay have.
What's the best way to do this?
Maybe I could put all the photos I've downloaded to the same folder and skip the ones with names that already exist in the folder I'm pulling from? How to do that?
Is that even the best way? Does an easier way to do this exist?
If so... how?
I'm on arch linux by the way, in case the distribution effects your suggested answer.
adb shell find "/sdcard/DCIM" -iname "*.jpg" | tr -d '\015' | while read line; do adb pull $line; done;
^that works well enough.
From here.
The adb-sync tool worked for me: https://github.com/google/adb-sync
Note that I had to make several changes to the source code to get it working for my use-case (invalid paths for Windows causing crash, Python version mismatch apparently, etc -- for details, see issues I commented in), but it ended up being the only way I was able to retrieve my files from a corrupted data partition.
(The adb pull of the whole directory would crash on various files, and I didn't want to manually have to delete each one then restart the whole transfer. With adb-sync [+my modifications] it would just fail that one file then continue.)
Regarding your question of having it only transfer new files, I believe adb-sync does that automatically if a file hasn't been changed. If you don't want it to re-transfer an existent file ever (ie. even if the file has been updated), I think that's what the flag mentioned here is for: https://github.com/google/adb-sync/issues/22

How to change ADB Device Names during build process

I am currently working with multiple android builds on different hardware. I am having an issue where they all have the same serial number, 0123456789ABCDEF. This makes it impossible to use adb when I connected to two or more devices at once, because the adb doesn't know which one to talk to.
I know that the name is being pulled from /sys/class/android_usb/android0/iSerial and if I wanted to I could change it there once the build is complete. Ideally though, I want that file to be set during the build depending on the build settings. I want to know where that file is being generated during the build. I believe it's being set either somewhere in barebox or in /system/core/adb, but have had no luck on the things I've tried editing.
If anyone has ran into this, any help would be greatly appreciated.
Edit:
Found the solution.
This can be found in /device/company_name/device_name/init.device_name.usb.rc
on boot
write /sys/class/android_usb/android0/iManufacturer ${ro.product.manufacturer}
write /sys/class/android_usb/android0/iProduct ${ro.product.model}
write /sys/class/android_usb/android0/iSerial ${ro.serialno}
echo "ro.serialno is ${ro.serialno}"
write /sys/class/android_usb/android0/idVendor 0451
write /sys/class/android_usb/android0/idProduct D101
..."
Change the ro.serialno to whatever you'd like.

How to use sqlite under ubuntu with teminal?

i just want to know how to get the android loacal-app Contact' database,i want to check the raw_contact or data table with terminal.what tools i need or what is the orders?Thanks.
From what I understand from your question you want to use a CLI tool to inspect the Android contact's database. AFAIK the database itself should be located in
/data/data/com.android.providers.contacts/databases/contacts2.db
But could possibly change depending on the manufacture?
As far as using a local tool on your Ubuntu install you'd first need to get the platform SDK to use ADB to pull the database off your device then use a local tool to manipulate or examine the database. Note:Your device will need to be rooted to pull the database.
For example on the SQLite website they provide a binary for Linux to inspect databases. It can be located here: http://www.sqlite.org/download.html but I'm sure there are a couple more floating around due to SQLite being an open standard.
Hope this answers your questions.

Are there any tools for monitoring database during debugging in android?

I want to monitor the contents of my database during debugging, i.e, I want to see all the rows in the tables, and see the updates as and when they take place. Currently, I'm using android.util.Log. But, if there is a better way to do it, that would be nice. Thanks.
The database file is in the /data/data/package_name/database
You can:
use adb shell, use command "sqlite3 your_database" to manage the database, also there exists a tool in sdk called sqlite3 (a command line tool)
push the database file out, use a sqlite browse tool to check for details (tools such as sqliteadmin, sqlitebrowser)
I asked the same question before: Logging SQL statements using SQLiteDatabase . Seems like there's no decent logging tool for SQLite on Android. It is a real shame.

Problem with sqlite in the android device

I am using sqlite to save some string values in the database, my app works perfectly in the emulator. But when I tried it on the Samsung Galaxy Tab, the log cat says that there are not such tables... before mounting the apk files to the device I have tried opening it in the archive mode and found the database and the tables secure in my "assets" folder.
Can any one tell me whats going wrong with me ?
thanks in advance...
Happy coding
Databases don't belong in the assets-folder! You should use a SQLiteOpenHelper-class to create and update your Database when it's needed.
Tutorial (or simply Google for it).
I have experience with the same thing you are experiencing now. This is a classic in device manufacturer fragmentation. It has happened to me before when trying to run an application on a Samsung Nexus S phone that had a method to copy a already existing database to the application from assets on install (i am guessing that's what you are doing at the moment). so long story short, after quite some testing the best and only solution i could find was to actually do the manual work and create the database with the help of the SQLiteHelper methods and table creating queries and recreate the same scheme. this method works 100% so far on every phone i have tried it so that's the safest thing you can do.
Hope this helps.
The db file should be available in "/data/data/YOUR_PACKAGE/databases/" folder in your device.
If this is the first time you are creating the db then you should copy the db file from your assets folder into the above location (the first time when you access the database).

Categories

Resources