adb: Update/rescan contacts without rebooting the android device - Other Tools & General Discussion

I am trying to load the contacts via db directly using following commands.
Code:
adb shell rm /data/data/com.android.providers.contacts/databases/contacts2.db
adb pull /data/data/com.android.providers.contacts/databases/contacts2.db <PATH>
adb push <PATH>/contacts2.db /data/data/com.android.providers.contacts/databases/
However, I have to restart my devices(trying with multiple Android phones) before it can update the contacts.
Is there a way to get the updated contacts from the pushed/removed db (no contacts) without restarting the devices?
I cannot use any third party app due to project requirements. Preferable solution would be via adb or similar command line tools.
Regards,
RA

Related

ADB Uninstall Failure

I adb pushed some .apks from a Froyo zip onto my mytouch1.2 but they didnt work...
when I try to uninstall them I get a failure message... and when I try adb shell... blah blah blah..."ls" the files arent there...
any help is appreciated
how to uninstall
I've tried a few methods.
The one I've found that works the best is this : mv <source> <destination> ...it's supposed to be a move command but it actually deletes files. rm also likely does the same (eg rm <filename.filetype OR foldername>)
BEFORE using these commands though, type in
adb shell <enter>
cd <foldername> <enter>
cd <foldername> <enter>....to get to folder (directory) of your choice
**TO get to app directory to uninstall apps, do cd system -->cd app -->mv appname.apk
I use the /sdcard as the destination for the mv command - I noticed the files NEVER get moved so this is just a delete command.
You could also delete a whole folder with this command. do cd system
mv app /sdcard
(this would delete the entire app folder/directory from the device).
That's pretty much it. Works for me. Was trial and error though - adb uninstall command ALWAYS resulted in 'failure ' or 'file not found' and the same with adb shell --> # uninstall appname.apk ---> 'failure'.
So I hope this works for you! Good luck .
str8arrow
NOTE: I've had an awful time because my stupid tablet has refused to download things from the market. It stalls in the initial 'starting download' bit and then just hangs, and then says 'download failed'. Apparently there's some problem with the sync'ing but I can't log into Gmail or GoogleTalk to try to resolve this (Gmail won't allow me to enter anything - left it on overnight and it said 'getting mail' / 'sync in progress' and the sync never completed after 12 hrs. The GoogleTalk app just displayed a black screen. So I am getting nowhere.
if anyone knows how to fix this pls let me know. I'm apparently not the only one. Others /various tablets have had similar issues - I have a 7" BPDN (Pandigital black novel).
Please, help!
str8arrow
adb shell <enter>
then
cd system
cd app
mv <filename.apk> <destination> (this should move the file BUT it never shows up in destination or elsewhere, so this is effectively a delete command, you could also do mv <foldername> <destination> to delete a whole folder.
**I usu. use /sdcard as my destination. so mv filename.apk /sdcard
OR
cd system
cd app
rm <filename.filetype> does the same sort of thing.
(eg adb shell <enter>
**I tried the uninstall commands listed but.. (adb uninstall-->'failure', or 'file not found' etc, adb shell --> uninstall --> same error).
Commands for removing apps.
I run as root on all my OS's, so I don't have to navigate to my sdk directory. I just type "adb devices", I don't know how your adb is setup, but get adb running and run these commands.
adb remount
adb shell
rm /system/app/whatever.apk
Or whatever path you pushed the files to. Try running fix_permissions to make your apps run properly and stop FC issues

Crashing Accounts & Sync after htc sync app removal -- a better fix

After flashing damage control 2.3.2 and removing HTC sync apps, the "accounts and sync" control panel was giving me FCs... the sledgehammer advice i found in the DC 2.3.2 announcement was
-If your accounts & sync FC after upgrading from another rom you can try to do the following but be warned you will need to resync everything
Code:
Code:
adb remount
adb shell rm /data/system/accounts.db
adb reboot
Yeah, that works, but there's a whole lot of logging-in to do all over again, which is such a bother without a physical keyboard, so here's a modest improvement...
*new & improved* a nice little cryptic incantation to fix the problem without re-syncing...
SO where does the nudge get sent for this to find its way into dconfig??
Code:
adb shell
cd /data/system
echo 'delete from accounts where type LIKE "com.htc%";' |sqlite3 accounts.db
--- before I came up with the SQL approach, I did it the hard way ---
Code:
adb remount
adb pull /data/system/accounts.db /tmp/
EDIT the accounts.db file (I used the SQLite Manager extension in firefox) and delete all of the com.htc rows from the "accounts" table (I had three for weather, news, and stock applications)...
Code:
adb push /tmp/accounts.db /data/system/accounts.db
adb shell reboot
Would anyone care to suggest a more efficient and polished way of doing this same operation? Hmmmmmmmmmm... I guess that'd be an sqlite command-line incantation to be run on the phone...
I just do a factory reset after deleting everything and solves my fc problems.
Wow, thanks! That saved me a lot of headache! I also shortened it into a one-liner:
To check the list beforehand:
Code:
adb shell "echo 'select * from accounts;' | sqlite3 /data/system/accounts.db"
To fix the HTC account issues (as per your method):
Code:
adb shell "echo 'DELETE FROM accounts WHERE type LIKE \"com.htc%\";' | sqlite3 /data/system/accounts.db"

adb push/pull with wildcards (or adb shell cp /foo/*/bar_*)

I've been working on a bash script that automates commonly used adb and fastboot commands. Its pretty much done, but I have one option I'm trying to incorporate that takes a backup (through the adb twrp interface) and automatically puts it on the host machine.
It needs to wildcard both the folder the backup is in, and the date I append to the backup name. From the research I've done adb push/pull doesn't accept wildcards for whatever reason. I've been playing around with adb shell, but adb shell can't communicate with the host machine (to cp the file back to it), and that makes sense since its a shell on the device.
So, how would you go about taking a backup on the remote device (through a command on the host machine), and then copying the backup to the host machine?
Code:
adb pull /data/media/0/TWRP/BACKUPS/*/backup_* /home/ninja/Downloads/
Doesn't work because adb doesn't accept wildcards.
Code:
adb shell cp /data/media/0/TWRP/BACKUPS/*/backup_* /home/ninja/Downloads/
Doesn't work because its trying to find
Code:
/home/ninja/Downloads/
on the remote device.
I'm pretty new to scripting/programing, so any and all relevant input would be greatly appreciated.
Anyone?

How to avoid running a new adb for each command send?

I'm trying to send runtime commands like:
adb.exe -s 127.0.0.1:5555 shell screencap /sdcard/ss.png
To the adb server running, using SendMessage / Windows Message, does adb even support it? If so I wonder how it needs to be sent.
I know I could pass runtime commands using cmd or running directly to the adb.exe.
My goal is to keep just one running and avoid spamming a new ADB for each command sent. Is it even possible?
Any other suggestion is welcome.
When command
Code:
adb start-server
is run then one ADB ( server ) session gets established.
This session lasts untill command
Code:
adb kill-server
is run.
Look into Windows Task Manager.
The question is how to communicate with this window using sendmessage or any other option that does involve you manually typing in the console.
ADB isn't a Windows executable you can send messages to, it only offers a CLI.

How to access data folder from non-rooted device?

A few weeks ago one of my important apps started crashing on open.
Since I have important informaiton saved on that app I need to obtain it.
Is there a way to access that package folder (and that app is not debuggable) with adb or shell?
When I try to access via adb and shell the result it Permission denied.
I can't root the phone, so this is out of the quesiton.
I'm using Google Pixel 1 with Android 10 Build - Build/QP1A.191005.007.A3)
There isn't any way to access /data/data/ as a normal user or shell user, the only user able to access that is root, at least according to the permissions.
You could try to backup using "adb backup package", then you could apply this backup back on another phone or on this same app after reinstalling it.
bystroy said:
A few weeks ago one of my important apps started crashing on open.
Since I have important informaiton saved on that app I need to obtain it.
Is there a way to access that package folder (and that app is not debuggable) with adb or shell?
When I try to access via adb and shell the result it Permission denied.
I can't root the phone, so this is out of the quesiton.
I'm using Google Pixel 1 with Android 10 Build - Build/QP1A.191005.007.A3)
Click to expand...
Click to collapse
Temporarily root phone's Android, means add su cmdlet what is suitable, and then mount the partition in question as RW by means of ADB applying su.
Example:
Code:
adb devices
adb push <SU-BINARY> / data/local/tmp/
adb shell "chmod +x /data/local/tmp/su"
adb shell "/data/local/tmp/su -c 'mount -t auto -o rw,remount <PARTITION-IN-QUESTION>'"
adb pull "<DIRECTORY-TO-PULL>" <LOCATION-ON-PC>

Categories

Resources