Background technology
In the prior art, find that the means that the smart mobile phone application data is upgraded mainly contain: the Trigger mechanism of Observer Pattern (android Observer) and application data base table.
Observer Pattern is called issue-subscription (Publish/Subscribe) pattern, model-view (Model/View) pattern, source-audiomonitor (Source/Listener) pattern or subordinate (Dependents) pattern again.Observer Pattern has defined a kind of dependence of one-to-many, lets a plurality of observer's objects monitor some subject simultaneously.When this subject changes, can notify all observer's objects on state, make them can upgrade oneself automatically.
The Trigger mechanism of application data base table, it closely links to each other with table, sets up the part of visual tabulation based on table.It can not be called by explicit, and after the user created trigger, when the data in the table were inserted, deleted or revise, trigger is operation automatically.Trigger mechanism can make a plurality of different users keeping the operation of making amendment under data integrity and the conforming good environment.
Above-mentioned Observer Pattern can only monitor the table level, that is to say, can only confirm that through Observer variation has taken place which table, can not navigate to which bar record variation has taken place.Trigger mechanism excites treatment S QL operation when the variation that monitors record, application processing function is skipped in the variation of data recording, makes the user to do further processing to using the record variation.
Summary of the invention
In order to solve the deficiency that prior art exists, the object of the present invention is to provide a kind of quick locating cellphone application data method for updating, for wanting the data monitored table; At first create the state before base table upgrades with record data; Utilize Observer Pattern (android Observer) then when Data Update, confirm to take place the Data Update tables of data, the state and the base table data recorded state of the tables of data after comparison is upgraded; Find out both inconsistent records, the record that specified data is upgraded.
To achieve these goals, a kind of data fast classification method provided by the invention may further comprise the steps:
1) selection needs the field of data monitored table and needs monitoring, creates base table, utilizes Observer Pattern then, when Data Update, confirms to take place the Data Update tables of data;
The state and the base table data recorded state of the tables of data after 2) comparison is upgraded are found out both inconsistent records, the record that specified data is upgraded;
3) the above-mentioned Data Update of record records database.
Other features and advantages of the present invention will be set forth in instructions subsequently, and, partly from instructions, become obvious, perhaps understand through embodiment of the present invention.
Embodiment
Below in conjunction with accompanying drawing the preferred embodiments of the present invention are described, should be appreciated that embodiment described herein only is used for explanation and explains the present invention, and be not used in qualification the present invention.
Method of the present invention, for wanting the data monitored table, the record original state is monitored application data based on Observer Pattern (android Observer), and when data variation, variation has taken place in which tables of data that can be determined to which application; Then, tables of data state and original state after relatively changing are found out variation, confirm that variation has taken place which bar record.
Fig. 1 is according to quick locating cellphone application data method for updating process flow diagram of the present invention, below with reference to Fig. 1, quick locating cellphone application data method for updating of the present invention is described in detail:
At first, in step 101, selection will be monitored the tables of data and the field that needs monitoring at application data place, and finds out and can indicate the field that needs the monitoring field whether to change.These field values that can indicate Monitoring Data whether to change are linked to be character string, and the cryptographic hash of calculating character string, according to these cryptographic hash, be recorded as the original state of Monitoring Data table, create base table; The main field of base table comprises: " _ id " (Monitoring Data table sign), and " state_value " (state value), " uri " (indication data monitored table), " recordId " (corresponding in the data monitored table _ id).State value is the cryptographic hash of calculating according to the monitoring field of Monitoring Data table.Here the field of selecting data monitored table and monitoring is to select according to user's needs, scanning data monitored table record original state;
In step 102, when android Observer monitors Data Update,, contrast the original state of base table according to " uri " specified data data updated table, find out the physical record of data variation.
The method of two tables of contrast is: at first utilize " uri " press order that " recordId " successively decrease from base table taking-up data D1, utilize order that uri successively decreases by " _ id " from the data updated table D2 that fetches data.Then, get D1 successively, the D2 record compares.
If a) D1 " recordId " is greater than D2 " _ id ", explain that the record that " _ id " in the corresponding Monitoring Data table of D2 equals " recordId " deletes.Get next bar record of D1, the D2 record is constant, compares next time.As shown in table 1, recordId>_ id, delete _ id=6.
Table 1: data deletion
(D1)recordId |
(D2) _id |
9 |
9 |
8 |
8 |
6 |
? |
5 |
5 |
4 |
4 |
B) if D1 " recordId " less than D2 " _ id ", explains that this record in the corresponding Monitoring Data table of D2 is the new record that adds.Get next bar record of D2, the D1 record is constant, compares next time.As shown in table 2, recordId < _ id, interpolation _ id=9.
Table 2: data are added
(D1)recordId |
(D2) _id |
? |
9 |
8 |
8 |
6 |
6 |
5 |
5 |
4 |
4 |
C) if D1 " recordId " equals D2 " _ id "; Then calculate the corresponding cryptographic hash of field of the monitoring of data monitored table; And with base table in corresponding " state_value " compare, if two values are identical, the expression data are not upgraded; If different, explain that this record in the corresponding Monitoring Data table of D2 has upgraded.Get D1, next bar record of D2, compare next time.As shown in table 3, in corresponding cryptographic hash not simultaneously, Data Update is arranged.
Table 3: Data Update
(D1)recordId |
(D2) _id |
9 |
9 |
8 |
8 |
6 |
6 |
5 |
5 |
4 |
4 |
D) if there is not record among the D1, also have record among the D2, explain that these records all are new the interpolations among the D2.As shown in table 4, there is not record among the D1, also have record among the D2, these corresponding data are new interpolations in the Monitoring Data table.
Table 4:
(D1)recordId |
(D2) _id |
? |
5 |
? |
4 |
? |
3 |
? |
2 |
|
1 |
E), also have record among the D1, explain among the D2 if there is not record among the D2 " _ id " equal " recordId " these records all deleted.As shown in table 5, there is not record among the D2, also have record among the D1, these corresponding in Monitoring Data table data have all been deleted.
Table 5:
(D1)recordId |
(D2) _id |
9 |
? |
8 |
? |
6 |
? |
5 |
? |
4 |
|
In step 103, write down the database that records of above-mentioned variation, supply other to use and use.
At present, on smart mobile phone, there is plurality of applications that the variation of some data of other application extremely is concerned about, hopes to obtain the change information of these application.Such as, handset dialing need be known the variation of address book data, so that through the address list dialing, need know the variation of short message, knows that which contact person gets in touch often, so that the user finds these contact persons the most easily.Search need be known the variation of each application data for another example, so that existing information is arrived in user search, search less than non-existent information, or the like.But the current means of other application change of finding also are nowhere near, and adopt quick locating cellphone application data method for updating of the present invention, and Monitoring Data is upgraded in real time, confirm data updated takes place, and the application of notice needs.
One of ordinary skill in the art will appreciate that: the above is merely the preferred embodiments of the present invention; Be not limited to the present invention; Although the present invention has been carried out detailed explanation with reference to previous embodiment; For a person skilled in the art, it still can be made amendment to the technical scheme of aforementioned each embodiment record, perhaps part technical characterictic wherein is equal to replacement.All within spirit of the present invention and principle, any modification of being done, be equal to replacement, improvement etc., all should be included within protection scope of the present invention.