I write little application for design message history from whatsapp app. The whatsapp app is stored data into sqlite db.
First of all I decrypt the db.
Secondly, I see that the DB have a table for messages, with those columns:
Code:
TABLE messages
(
_id INTEGER PRIMARY KEY AUTOINCREMENT,
key_remote_jid TEXT NOT NULL,
key_from_me INTEGER,
key_id TEXT NOT NULL,
status INTEGER,
needs_push INTEGER,
data TEXT,
timestamp INTEGER,
media_url TEXT,
media_mime_type TEXT,
media_wa_type TEXT,
media_size INTEGER,
media_name TEXT,
media_hash TEXT,
media_duration INTEGER,
origin INTEGER,
latitude REAL,
longitude REAL,
thumb_image TEXT,
remote_resource TEXT,
received_timestamp INTEGER,
send_timestamp INTEGER,
receipt_server_timestamp INTEGER,
receipt_device_timestamp INTEGER,
raw_data BLOB,
recipient_count INTEGER
)
So, there have a records for images, video, audio and etc. (they are stored on raw_data column)
Now, for every record I try to save to local directory on my pc, as follows:
First way:
Code:
File.WriteAllBytes(Path.Combine(directoryPath, msg.Media.MediaName)), msg.Media.RAW_DATA);
But I see, that it working only for image files, not for audio and video files..
Second way:
Code:
using (FileStream fs = new FileStream(Path.Combine(directoryPath, msg.Media.MediaName), FileMode.Create))
{
using (BinaryWriter writer = new BinaryWriter(fs))
{
writer.Write(msg.Media.RAW_DATA);
}
}
but I get same results
the audio and the video are not stored on the db?
Anybody?
Sent from my HTC One using XDA Premium 4 mobile app
I think that nobody knows the answer:\
Related
I have searched and searched but not found anything that is suitable.
I am looking for a menu add-on or context menu that will allow me to:-
Create a calendar appointment/meeting request with a contact that does not have email address so cannot use the meeting request as an attendee.
i.e. 'Create Meeting With':
The new appointment would have the subject and location fields populated from the contact Name, default number and default Address.
I have seen this functionality in Agenda One and partially in the MS Powertoy cntctool.exe(copies the contact name and address to the appointment notes if no email address exists).
Ideally I do not want to install a completely new Calendar app like AgendaOne for this 1 piece of functionality so does anyone know of an alternative for an add-on to achieve this??
The code(I guess) would be along the lines of...
Appointment newappoinment = new Appointment();
newappoinment.Subject
="Meet with"contactPicker.SelectedContactName,
"("contactPicker.SelectedContactNumber")";
newappoinment.Location = contactPicker.SelectedContactAddress;
newappo inment.Start = DateTime.Now;
newappoinment.Duration = new TimeSpan(01, 00, 00);
newappoinment.ReminderVibrate = true;
newappoinment.ReminderSound = true;
newappoinment.ReminderRepeat = true;
newappoinment.ReminderSet = true;
using (OutlookSession session = new OutlookSession())
{
session.Appointments.Items.Add(newappoinment);
session.Dispose();
}
MessageBox.Show("Meeting Added");
Many thanks for anyone who can help,
Mick
First of all I would like to say hello to everyone as this is my first post to this forum
I have android phone (HTC Desire Z) for about a week now an I just have to share how insanely awesome this device is! To show you what I mean I'll describe how to fix the problem with incorrect transfer of calendar notes from my old Nokia N95 8GB to new HTC.
I rooted my HTC and uploaded newest Sense ROM (2.1) with Android 2.3.3 from the forum (thanks for making that possible!).
Now, to the problem. I wanted to transfer calendar notes from N95 to my new phone (more than 200 of them). Using the transfer application, the notes got copied but all had lost their alarms! This was disaster for me as I'm depending on these notes on daily basis. I googled for this problem but didn't find any solution. But this is the Android - everything can be done, right?
So, the solution. I've read somewhere that Android stores data of all it's applications as sqlite databases. As I professionally work with sql databases this seemed to be to good to be true... But no, it is true
To the point then. It is possible to fix my calendar by executing sql queries directly against the database itself!
I've found and pulled the calendar database file from the device by
Code:
adb pull /data/data/com.android.providers.calendar/databases/calendar.db
and got inside
Code:
sqlite3 calendar.db
Let's see what tables we have
Code:
.tables
Code:
Attendees EventsRawTimes android_metadata
CalendarAlerts ExtendedProperties easSyncInfo
CalendarCache Instances easTracking
CalendarMetaData Reminders pcscSyncInfo
Calendars _sync_state pcscTracking
Events _sync_state_metadata view_events
Interesting tables are Events and Reminders. Let's extract their ddls
Code:
.schema Events
.schema Reminders
Code:
CREATE TABLE Events (_id INTEGER PRIMARY KEY AUTOINCREMENT,_sync_account TEXT,_sync_account_type TEXT,_sync_id TEXT,_sync_version TEXT,
_sync_time TEXT,_sync_local_id INTEGER,_sync_dirty INTEGER,_sync_mark INTEGER,
calendar_id INTEGER NOT NULL,htmlUri TEXT,title TEXT,eventLocation TEXT,description TEXT,
eventStatus INTEGER,selfAttendeeStatus INTEGER NOT NULL DEFAULT 0,commentsUri TEXT,
dtstart INTEGER,dtend INTEGER,eventTimezone TEXT,duration TEXT,allDay INTEGER NOT NULL DEFAULT 0,
visibility INTEGER NOT NULL DEFAULT 0,transparency INTEGER NOT NULL DEFAULT 0,
hasAlarm INTEGER NOT NULL DEFAULT 0,hasExtendedProperties INTEGER NOT NULL DEFAULT 0,
rrule TEXT,rdate TEXT,exrule TEXT,exdate TEXT,originalEvent TEXT,originalInstanceTime INTEGER,
originalAllDay INTEGER,lastDate INTEGER,hasAttendeeData INTEGER NOT NULL DEFAULT 0,
guestsCanModify INTEGER NOT NULL DEFAULT 0,guestsCanInviteOthers INTEGER NOT NULL DEFAULT 1,
guestsCanSeeGuests INTEGER NOT NULL DEFAULT 1,organizer STRING,deleted INTEGER NOT NULL DEFAULT 0,
dtstart2 INTEGER,dtend2 INTEGER,eventTimezone2 TEXT,syncAdapterData TEXT, importance INTEGER NOT NULL DEFAULT 1,
iCalGUID TEXT,last_update_time TEXT,parentID INTEGER,facebook_source_id TEXT,facebook_type TEXT,
facebook_avatar_large TEXT,facebook_avatar_small TEXT,facebook_avatar_local TEXT,
MeetingStatus INTEGER NOT NULL DEFAULT 0);
Code:
CREATE TABLE Reminders (_id INTEGER PRIMARY KEY,event_id INTEGER,minutes INTEGER,method INTEGER NOT NULL DEFAULT 0);
and let's take a look at the data inside
Code:
SELECT * FROM Events WHERE _id=208;
SELECT * FROM Reminders WHERE event_id=208;
for example
Code:
208|PC Sync|com.htc.pcsc|||||1||1||Test1||||1||1304445600000|1304449200000|Europe/Brussels|P3600S|0|0|0|1|1|||||||||1|0|1|1|Outlook|0|||||1|8effd54b-5cd3-451c-8602-2d969f1a84c4|2011-05-03 17:20:36|||||||0
and
Code:
203|208||0
Interesting columns are Events.hasAlarm, Reminders.minutes and Reminders.method.
So recall that I have over 200 calendar entries that had lost their alarms during transfer. How to fix this? Simply
Code:
UPDATE Events SET hasAlarm=1;
UPDATE Reminders SET method=1;
UPDATE Reminders SET minutes=10;
Now put the modified database back to the phone
Code:
adb push calendar.db /data/data/com.android.providers.calendar/databases/calendar.db
and reboot.
And that's it. All alarms are now set properly and work! To attain Nokia-like calendar alerts I'm using application 'Calendar Snooze' and it works like a charm!
Thanks for reading and sorry for being overjoyed but sheer possibility to fix the data in the cellphone by directly accessing it's sql database is so amazing
Maybe for you guys it's not so amazing after all but for someone who just switched from Nokia and found out something like that for the first time it's incredible.
I hope that this post will possibly help someone with similar problem one day
Kind regards,
dominik6
PS.
The possibilities are endless. You can add indices to tables (to maybe speed up some weird searches); add triggers (for example it's easy to do a inside-database backup by using an after insert trigger to duplicate data to another table), one can bulk update/insert/delete entries in calendar, and so on...
PPS.
SMS and contacts are also stored in sqlite databases...
Ok, I don't get it.
Porting CM7 and I have an odd one - the stock email application blows up when an account is added. Tracing it down I found the problem - the Sqlite schema is defective. Here's what I have in /data/data under the appropriate directory, examined by Sqlite3
sqlite> .schema account
CREATE TABLE Account (_id integer primary key autoincrement, displayName text, emailAddress text, syncKey text, syncLookback integer, syncInterval text, hostAuthKeyRecv integer, hostAuthKeySend integer, flags integer, isDefault integer, compatibilityUuid text, senderName text, ringtoneUri text, protocolVersion text, newMessageCount integer, securityFlags integer, securitySyncKey text, signature text, accountColorinteger);
Note the last field. There's supposed to be a space there; when the table was created the type statement was obviously keyed next to the field name without the required space. It also appears that SQLite is perfectly happy to create a field in a table without an explicit type declaration, which disturbs me, but it is what it is.
Here's the thing - obviously somewhere there's a declaration of that variable and type in some file somewhere. Right?
Well, where is it then - because I can't find it with a complete pass through the source using find / grep!
Nevermind - found it. The android guys were cute with the defines in the code and it indeed was a missing space in the email provider source.....
No idea where to put this, admin; feel free to move or delete.
There's a lot of really cool custom theming going on with Android and an often important part of that is the visual indication of missed phone calls, new messages, new mail, etc. (unread bubbles next to app icons, in lockscreens, etc.). There's a host of solutions to get this info but for me e-mail counts had always been a bit of a issue. Missed phone calls are tracked by the Android system, and WhatsApp notifications can be counted from the notification bar with Tasker and reset when you open the app because your phone is the only place where you will check your WhatsApp messages. E-mail however is not centralized in Android (yet) so if you use anything else than Gmail the system won't know how many unread mails you have and you could uee a notification counter on your mail app but when a new email arrives it will put the counter on +1, if you then read the e-mail on another device (for example your computer) your notification counter on your phone will still be on +1 even though you read the mail.You then have to open your mail app to get the counter back to 0 again.
That why I made this PHP / Tasker solution for my IMAP mail. This is a PHP script that checks how many unread mails there are in your inbox:
PHP:
<?php
function mailCount($host, $login, $passwd) {
$mbox = imap_open($host, $login, $passwd);
$mail = '';
if($mail = imap_check($mbox)) {
$msgnos = imap_search($mbox, 'UNSEEN');
return $msgnos;
}
}
$hostname = '{imap.yourhost.com:143/imap}INBOX';
$username = 'your_username';
$password = 'your_password';
$count = mailCount($hostname, $username, $password);
if ($count != "") $number = sizeof($count);
else $number = 0;
echo $number;
Change yourhost, your_username and your_password and the port (143). (if you want to, add some extra security by doing IP or Cookie checks), put the PHP file online on your server. The script will then simply show a number of unread mails in your inbox.
Then you can use Tasker to read this number. Add a tasks (for example CheckMailCount) then add the action Net > HTTP Get. For 'Serverort' fill in the url of your script (http://www.yourserver.com/unreadmail.php) and set the Mime Type to 'text/*'. Then in the same task add an action Variables > Variable Set. Give the variable a Name (for example: %MAILCOUNT) and set it To %HTTPD. This will set the %MAILCOUNT variable to the result of the last http Get request ie. the number of unread mails.
You now have a tasker variable with the actual number of unread mails in your inbox.
I use this on my WidgetLocker lockscreen so I trigger the task on Event > Display > On. I added a third action in the CheckMailCount action to set a Zooper Variable (Plugin > Zooper Widget Pro >Edit > ZW Variable = MAILNOTI, ZW Text = %MAILCOUNT) you could also make this %HTTPD straight away if you don't use the variable for anything else. You then have the #TMAILNOTI# variable in Zooper to use to display how many unread mails you have in a widget. I don't use the count but I display a mail icon indicating that I have a new mail if the #TMAILNOTI# is anything but 0. I do this by adding a bitmap in Zooper of a mail icon and then in Avanced Parameters I put
$#TMAILNOTI#=0?/sdcard/icons/nomail.png$
This tells Zooper that if the variable #TMAILNOTI# = 0 it should use the bitmap nomail.png in my icons folder on the sd card. nomail.png in my case is simply an empty transparent png.
Hope this helps somebody!
nielshtc said:
No idea where to put this, admin; feel free to move or delete.
There's a lot of really cool custom theming going on with Android and an often important part of that is the visual indication of missed phone calls, new messages, new mail, etc. (unread bubbles next to app icons, in lockscreens, etc.). There's a host of solutions to get this info but for me e-mail counts had always been a bit of a issue. Missed phone calls are tracked by the Android system, and WhatsApp notifications can be counted from the notification bar with Tasker and reset when you open the app because your phone is the only place where you will check your WhatsApp messages. E-mail however is not centralized in Android (yet) so if you use anything else than Gmail the system won't know how many unread mails you have and you could uee a notification counter on your mail app but when a new email arrives it will put the counter on +1, if you then read the e-mail on another device (for example your computer) your notification counter on your phone will still be on +1 even though you read the mail.You then have to open your mail app to get the counter back to 0 again.
That why I made this PHP / Tasker solution for my IMAP mail. This is a PHP script that checks how many unread mails there are in your inbox:
PHP:
<?php
function mailCount($host, $login, $passwd) {
$mbox = imap_open($host, $login, $passwd);
$mail = '';
if($mail = imap_check($mbox)) {
$msgnos = imap_search($mbox, 'UNSEEN');
return $msgnos;
}
}
$hostname = '{imap.yourhost.com:143/imap}INBOX';
$username = 'your_username';
$password = 'your_password';
$count = mailCount($hostname, $username, $password);
if ($count != "") $number = sizeof($count);
else $number = 0;
echo $number;
Change yourhost, your_username and your_password and the port (143). (if you want to, add some extra security by doing IP or Cookie checks), put the PHP file online on your server. The script will then simply show a number of unread mails in your inbox.
Then you can use Tasker to read this number. Add a tasks (for example CheckMailCount) then add the action Net > HTTP Get. For 'Serverort' fill in the url of your script (http://www.yourserver.com/unreadmail.php) and set the Mime Type to 'text/*'. Then in the same task add an action Variables > Variable Set. Give the variable a Name (for example: %MAILCOUNT) and set it To %HTTPD. This will set the %MAILCOUNT variable to the result of the last http Get request ie. the number of unread mails.
You now have a tasker variable with the actual number of unread mails in your inbox.
I use this on my WidgetLocker lockscreen so I trigger the task on Event > Display > On. I added a third action in the CheckMailCount action to set a Zooper Variable (Plugin > Zooper Widget Pro >Edit > ZW Variable = MAILNOTI, ZW Text = %MAILCOUNT) you could also make this %HTTPD straight away if you don't use the variable for anything else. You then have the #TMAILNOTI# variable in Zooper to use to display how many unread mails you have in a widget. I don't use the count but I display a mail icon indicating that I have a new mail if the #TMAILNOTI# is anything but 0. I do this by adding a bitmap in Zooper of a mail icon and then in Avanced Parameters I put
$#TMAILNOTI#=0?/sdcard/icons/nomail.png$
This tells Zooper that if the variable #TMAILNOTI# = 0 it should use the bitmap nomail.png in my icons folder on the sd card. nomail.png in my case is simply an empty transparent png.
Hope this helps somebody!
Click to expand...
Click to collapse
This looks way to confusing but I get it a little bit... lets say I want to use UCCW tasker variable option to show the counts...:silly:
i used this code to delete sms but it is not working & not showing any error.
Code:
this.getContentResolver().delete(Uri.parse("content://sms/" + cur.getLong(0)), null, null);
any idea to delete SMS from non default sms app?????