1

I'm creating an app which automatically lists the calls and sms of a day in the order of time. I completed the codes to store both sms and calls to the Database using services. I have 2 table:

Table Call(number, name, call_type, call_duration, date, time, time_in_milliseconds (long)) 
Table Sms(number, name, message, date, time, time_in_milliseconds (long)) 

I need to compare both tables based on time_in_milliseconds, and retrieves the entire row and set to text view in the order of time_in_milliseconds increases.

4

1 回答 1

2

If I understand correctly you can use this code:

        ourDatabase.rawQuery("SELECT number, name, call_type, call_duration, date, time, time_in_milliseconds " +
            " FROM Call " +
            " UNION " +
            " SELECT number, name, message, date, time, time_in_milliseconds " +
            " FROM Sms " +
            " ORDER BY time_in_milliseconds", null);
于 2013-10-06T16:23:13.653 回答