CN106681859B - Short message recovery method and device - Google Patents
Short message recovery method and device Download PDFInfo
- Publication number
- CN106681859B CN106681859B CN201611058986.3A CN201611058986A CN106681859B CN 106681859 B CN106681859 B CN 106681859B CN 201611058986 A CN201611058986 A CN 201611058986A CN 106681859 B CN106681859 B CN 106681859B
- Authority
- CN
- China
- Prior art keywords
- short message
- short
- backup file
- memory
- variable
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
- G06F11/1469—Backup restoration techniques
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The embodiment of the invention provides a method and a device for restoring short messages, wherein the method comprises the following steps: acquiring a short message backup file to be restored in a mobile terminal; and writing the short messages in the short message backup file into a memory at least twice, and writing the short messages into a short message database from the memory at least twice. The interval time between writing the short message backup file into the memory and writing the short message backup file into the short message database from the memory is short generally, so that the normal execution of the whole restoration operation is ensured.
Description
Technical Field
The present invention relates to the field of communication technologies, and in particular, to a short message recovery method and a short message recovery device.
Background
With the development of communication technology, mobile terminals such as mobile phones and watches have higher and higher usage rates in various aspects of work, study, daily communication and the like.
The user often uses short messages such as short messages and multimedia messages to communicate with other people, and the number of the short messages is large, especially for business people, the number of the accumulated short messages can reach tens of thousands, and the accumulated short messages are stored in a short message database.
In order to avoid the short message loss caused by system crash, mobile terminal replacement, etc., the user usually backs up the short message and restores the short message at an appropriate time.
At present, when restoring a short message, a backup file is generally read into a memory at one time and then written into a short message database.
When the number Of short messages in the backup file is too large, a large amount Of Memory is occupied, and even the short messages exceed the Memory (OOM, Out Of Memory), so that abnormal operation is caused.
Disclosure of Invention
In view of the above problems, embodiments of the present invention provide a short message recovery method and a corresponding short message recovery device, in order to solve the problem that the occupied memory is too large when the short message is recovered.
According to an aspect of the present invention, there is provided a method for restoring a short message, including:
acquiring a short message backup file to be restored in a mobile terminal;
and writing the short messages in the short message backup file into a memory at least twice, and writing the short messages into a short message database from the memory at least twice.
Optionally, the step of writing the short message in the short message backup file into the memory at least twice, and writing the short message in the short message database from the memory at least twice includes:
reading part of short messages from the short message backup file;
storing the part of the short messages to a memory;
writing the part of the short messages stored in the memory into a short message database;
judging whether all the short messages in the short message backup file are written into the short message database;
if yes, finishing writing the short message stored in the memory into the short message database;
if not, returning to the step of reading part of the short messages from the short message backup file.
Optionally, the step of reading a part of the short message from the short message backup file includes:
reading the value of the position variable to obtain a handle position;
reading a section of backup data from the short message backup file from the handle position;
identifying an ending identifier of the short message in the backup data;
dividing the backup data into data segments as short messages by taking the ending identifier as a node;
and writing the handle position of the backup data into the position variable.
Optionally, the step of reading a part of the short message from the short message backup file further includes:
extracting the remaining data segments when the short message is divided last time from the data variable;
splicing the last residual data segment before the first data segment to obtain a complete data segment;
and/or the presence of a gas in the gas,
and when the last data segment does not have the ending identifier, storing the last data segment into the data variable.
Optionally, the step of reading a part of the short message from the short message backup file further includes:
recording the length of the backup data;
and when the length is zero, finishing reading part of the short messages from the short message backup file.
Optionally, the step of storing the part of the short messages in the memory includes:
setting an array in a memory;
and writing the part of the short message into the array.
Optionally, the step of writing the part of the short messages stored in the memory into a short message database includes:
configuring an initial variable and a final variable, wherein the value of the initial variable is the sequence of the first short message in the array in all short messages, and the value of the final variable is the sequence of the short message next to the last short message in the array in all short messages;
assigning a value of the initial variable to a reducing variable;
judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable;
if yes, finishing writing the part of the short messages stored in the memory into the short message database;
if not, writing the short message positioned in the reduction variable in the array into a short message database;
and adding one to the value of the reduction variable, and returning to execute the step of judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable.
Optionally, the step of determining whether all the short messages in the short message backup file are written into the short message database includes:
judging whether the value of the reduction variable is larger than or equal to the total number of short messages in the short message backup file;
if yes, determining that all the short messages in the short message backup file are written into the short message database;
if not, determining that the short messages in the short message backup file are not completely written into the short message database.
According to another aspect of the present invention, there is provided a short message recovery apparatus, including:
the short message backup file acquisition module is used for acquiring a short message backup file to be restored in the mobile terminal;
and the multi-time storage module is used for writing the short messages in the short message backup file into the memory at least twice and writing the short messages into the short message database from the memory at least twice.
Optionally, the multi-time storage module comprises:
a part of short message reading sub-module, which is used for reading part of short messages from the short message backup file;
the memory storage submodule is used for storing the partial short messages to a memory;
the short message database writing submodule is used for writing the part of the short messages stored in the memory into the short message database;
the short message storage completion submodule is used for judging whether all the short messages in the short message backup file are written into the short message database; if yes, the storage ending sub-module is called, and if not, the part of short message reading sub-module is returned to be called;
and calling the storage ending submodule to end writing the short message stored in the memory into the short message database.
Optionally, the partial short message reading sub-module includes:
a handle position reading unit for reading the value of the position variable to obtain a handle position;
a backup data reading unit, configured to read a segment of backup data from the short message backup file from the handle position;
an end identifier recognition unit for recognizing an end identifier of the short message in the backup data;
a data segment dividing unit, configured to divide the backup data into data segments as short messages by using the end identifier as a node;
and the handle position updating unit is used for writing the handle position of the backup data into the position variable.
Optionally, the partial short message reading sub-module further includes:
a remaining data segment extracting unit, configured to extract, from the data variable, a data segment remaining when the short message was last divided;
the data segment splicing unit is used for splicing the last residual data segment before the first data segment to obtain a complete data segment;
and/or the presence of a gas in the gas,
and the residual data segment storage unit is used for storing the last data segment into the data variable when the last data segment does not have the ending identifier.
Optionally, the partial short message reading sub-module further includes:
a length recording unit for recording the length of the backup data;
and the short message reading ending backup unit is used for ending reading of part of the short messages from the short message backup file when the length is zero.
Optionally, the memory storage submodule includes:
the array setting unit is used for setting an array in the memory;
and the array writing unit is used for writing the partial short messages into the array.
Optionally, the short message database writing sub-module includes:
a variable value configuration unit, configured to configure an initial variable and a final variable, where the value of the initial variable is a ranking of a first short message in the array in all short messages, and the value of the final variable is a ranking of a short message next to a last short message in the array in all short messages;
the assignment module is used for assigning the value of the initial variable to a reduction variable;
the terminal variable judging unit is used for judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable; if yes, calling a short message database writing finishing unit, and if not, calling a short message reading unit;
the short message writing finishing database unit is used for finishing writing the part of the short messages stored in the memory into the short message database;
the short message restoration unit is used for writing the short messages positioned in the restoration variables in the array into a short message database;
and the reduction variable value changing unit is used for adding one to the value of the reduction variable and returning to call the traversal end judgment submodule.
Optionally, the storage completion determining sub-module includes:
the short message total number judging unit is used for judging whether the value of the restoring variable is larger than or equal to the total number of short messages in the short message backup file; if yes, calling a first confirmation unit, and if not, calling a second confirmation unit;
the first confirming unit is used for confirming that all the short messages in the short message backup file are written into the short message database;
and the second confirming unit is used for confirming that the short messages in the short message backup file are not completely written into the short message database.
The embodiment of the invention has the following advantages:
the embodiment of the invention regards the restoring operation as that for the short message backup file to be restored, one part of the short message backup file is partially written into the short message database, and the data of each part is relatively independent, so the short message backup file can be written into the memory at least twice and written into the short message database at least twice from the memory based on a lazy loading mechanism, because the time interval between writing the short message backup file into the memory and writing the short message backup file into the short message database from the memory is generally short every two times, the normal execution of the whole restoring operation is ensured, under the condition of large data volume of the short message backup file, one part of data is written into the memory each time and then written into the database, one memory is reused, the data volume written into the memory each time can be reduced, the occupation volume of the memory is reduced, and the data is ensured to be within the bearable range of the memory, the condition that the memory is exceeded is avoided, and normal operation is guaranteed.
Drawings
Fig. 1 is a flowchart illustrating steps of an embodiment of a method for restoring a short message according to the present invention;
fig. 2 is a flowchart illustrating steps of another embodiment of a short message retrieval method according to the present invention;
fig. 3 is a flowchart illustrating an example of reading a portion of a short message from a short message backup file according to an embodiment of the present invention;
fig. 4 is an exemplary flowchart for writing a part of short messages in a memory into a short message database according to an embodiment of the present invention;
fig. 5 is another exemplary flowchart for writing a part of short messages in a memory into a short message database according to an embodiment of the present invention;
fig. 6 is an exemplary flowchart of a moveToNext () function of an embodiment of the present invention;
fig. 7 is a block diagram illustrating a method and an apparatus for restoring a short message according to an embodiment of the present invention.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present invention comprehensible, embodiments accompanied with figures are described in further detail below.
Referring to fig. 1, a flowchart illustrating steps of an embodiment of a method for restoring a short message according to the present invention is shown, which may specifically include the following steps:
And step 102, writing the short messages in the short message backup file into a memory at least twice, and writing the short messages into a short message database from the memory at least twice.
In a specific implementation, the embodiments of the present invention may be applied to a mobile terminal that can communicate through a cellular network, such as a mobile phone, a tablet computer, a personal digital assistant, a wearable device (such as glasses, a watch, and the like), and the like.
The operating systems of these mobile terminals may include Android (Android), IOS, Windows Phone, Windows, and so on.
In order to enable those skilled in the art to better understand the embodiment of the present invention, in the present specification, Android is described as an example of an operating system.
Users use mobile terminals to communicate, and usually generate different amounts of short messages, such as short messages (sms), multimedia messages (mms), and so on.
The short messages are generally stored in a short message database of the operating system, and the content of the short messages displayed on a short message interface can be obtained by querying the short message database file, so that a user can browse, delete, modify and the like.
In the Android system, the short message database is mms.db, and the storage directory of the short message database is generally data/data/com.
Db generally has a reads table (table for storing session data), a sms table (table for storing short messages), a pdu table/part table (table for storing multimedia messages), a cancer _ address table (table for storing phone number), and the like.
In the embodiment of the invention, the short message stored in the short message database can be backed up in advance to generate the short message backup file, and the short message backup file is stored in a local storage or a cloud.
When the short message database is abnormal or the user manually restores the short message database, the short message backup file can be searched from the local storage, or the short message backup file can be downloaded from the cloud.
The embodiment of the invention regards the restoring operation as that for the short message backup file to be restored, one part of the short message backup file is partially written into the short message database, and the data of each part is relatively independent, so the short message backup file can be written into the memory at least twice and written into the short message database at least twice from the memory based on a lazy loading mechanism, because the time interval between writing the short message backup file into the memory and writing the short message backup file into the short message database from the memory is generally short every two times, the normal execution of the whole restoring operation is ensured, under the condition of large data volume of the short message backup file, one part of data is written into the memory each time and then written into the database, one memory is reused, the data volume written into the memory each time can be reduced, the occupation volume of the memory is reduced, and the data is ensured to be within the bearable range of the memory, the condition that the memory is exceeded is avoided, and normal operation is guaranteed.
Referring to fig. 2, a flowchart illustrating steps of another embodiment of a method for restoring a short message according to the present invention is shown, which may specifically include the following steps:
In the specific implementation, each time a part of short messages are read from the short message backup file and written into the memory, the number of the short messages read from the short message backup file is not constant because the data size of the short messages is not constant.
In one embodiment of the present invention, as shown in FIG. 3, step 202 may include the following sub-steps:
a substep S11 of reading the value of the position variable to obtain a handle position;
substep S12, reading a segment of backup data from the short message backup file from the handle position;
a substep S13 of recognizing an end identifier of a short message in the backup data;
substep S14, taking the ending identifier as a node, dividing the backup data into data segments as short messages;
and a substep S15, writing the handle position of the backup data to the position variable.
In the embodiment of the present invention, five variables and a constant are defined for recording nodes and data in the recovery process, where the five variables are respectively:
1、MessageArray
and the array represents the temporary storage of the short message data in the memory.
2、mPosition
And restoring the variable to represent the second mPosition short message in the short message backup file.
3、mStartPosition
The initial variable represents the first short message in the MessageArray, and is the mStartposition short message in the short message backup file.
4、mValidPosition
The final variable indicates that the next short message in the message array located next to the last short message is the mValidPosition short message in the short message backup file.
5、mFilePosition
And the position variable represents the handle position of the currently read short message backup file.
In addition, a constant value of N (N is a positive integer) indicates that the number of short messages in the MessageArray is N, and N short messages can be read into the database at the same time.
For logic clarity, embodiments of the present invention may encapsulate all five variables and a constant into a class, such as shortmessagecurser, as its member variables.
By applying the embodiment of the invention, the handle position of the short message backup file can be moved to the position when the last reading is finished from the reading of the mFilePosition, so that the short message which is not restored later in the short message backup file can be read by the mReader object.
In practical application, a segment of backup data can be read from the short message backup file according to the position of the handle.
The length (number of bytes) of the backup data is recorded, for example, in length, and the length can be set by those skilled in the art so that the number N of short messages included in the backup data is within an acceptable range.
When the length is zero, the reading of the short message backup file is finished, and the reading of part of the short messages from the short message backup file is finished.
In the short message backup file, the short message represents the data END position through an END identifier (such as END: VMSG), the END identifier is identified in the read backup data and a data segment is divided, and a complete (without the END identifier) data segment is a short message, and N short messages are used in total.
It should be noted that, because the data volume of the short message is not constant, when reading the backup data, a short message may be divided into two segments, and each segment is incomplete.
Therefore, if the remaining incomplete data segments are stored in the data variable when the short message is divided last time, the remaining data segments can be extracted from the data variable, and the remaining data segments are spliced before the first data segment to obtain the complete data segment.
In addition, when the last data segment does not have the ending identifier, the last data segment is stored in the data variable, and the short message is completed when the short message is divided next time.
If the partial short messages are successfully read from the short message backup file, the partial short messages can be stored in the memory to be written into the short message database.
In the embodiment of the present invention, an array may be set in the memory, and part of the short messages may be written in the array (MessageArray).
It should be noted that, since the number of the short messages read from the short message backup file is not constant, the number of the arrays may be dynamically set according to the number of the short messages.
And step 204, writing the part of the short messages stored in the memory into a short message database.
In a specific implementation, the short messages stored in the memory can be traversed and written into the short message database.
As shown in fig. 4, in sub-step S21, a shortcut message cursor may be obtained using a File object provided by an operating system, in sub-step S22, a moveToNext () function is called to move a position backward from before pointing to the first record to just pointing to the first record position, if true is returned, in sub-step S23, a getValue () function is called to extract a value on the cursor, i.e., a short message, and then in sub-step S24, the obtained short message is written into a short message database, and if False is returned, in sub-step S25, the operation is exited.
In one embodiment of the present invention, as shown in FIG. 5, step 204 may include the following sub-steps:
substep S31, configuring an initial variable and a terminal variable;
a substep S32 of assigning the value of the initial variable to a reduction variable;
a substep S33 of determining whether the value of the reduction variable is greater than or equal to the value of the terminal variable; if yes, performing the substep S34, otherwise, performing the substep S35;
substep S34, finishing writing the part of short messages stored in the memory into the short message database;
substep S35, writing the short message in the array in the reduced variable into a short message database;
and a substep S36 of adding one to the value of the reduction variable and returning to execute the substep S33.
In the embodiment of the present invention, the value of the initial variable mStartPosition is the sequence of the first short message in the array in all short messages, i.e. the value of one or the last terminating variable.
The value of the terminating variable mValidPosition is the sequence of the short messages next to the last short message in the array in all short messages, i.e. the amount of partial short messages is shifted on the basis of the value of the initial variable mStartPosition.
The restoring variable mPosition is the sequence of the current restored short messages in all short messages, and the value of the restoring variable mPosition is initially assigned to the value of the initial variable mStartPosition.
In a specific implementation, during initialization, an initial variable mStartPosition is 1, a terminal variable mValidPosition is mStartPosition + N, and a reduction variable mPosition is mStartPosition, where N is the number of short messages in the array MessageArray.
As shown in fig. 6, when the moveToNext () function is called to traverse the message array, it is determined in sub-step S41 whether mPosition > mCount and mPosition < mStartPosition are satisfied, if yes, it indicates that an error may occur, and in sub-step S42, information of an error (return fault) is returned, and if not, it indicates that the operation is normal.
Wherein, mCount is the total number of short messages in the short message backup file.
In sub-step S43, it is determined whether mPosition is greater than mValidPosition.
If mPosition is greater than or equal to mValidPosition, it indicates that the reading of the short message of the MessageArray is completed, in sub-step S44, a fillUpShortMessage (true) function is called, in sub-step S45, a correct (return true) message is returned, and the operation of traversing the MessageArray is stopped.
If mPosition < mValidPosition, it indicates that the message of MessageArray has not been read, and in substep S45, a correct (return true) message is returned, i.e. the second message of mPosition can be read and written into the message database.
And adding one to the value of mPosition, wherein mPosition is equal to mPosition +1, and returning to judge whether mPosition is greater than or equal to mValidPosition.
In the next operation of traversing the MessageArray, the value of the initial variable is the value of the final variable in the last operation of traversing the MessageArray, i.e. mStatposition ═ mValidPosition, on the basis of which the values of other variables are set, the final variable mValidPosition ═ mStatposition + N, the reduction variable mPosition ═ mStatposition, and the traversal of the MessageArray is continued.
And step 206, finishing writing the short messages stored in the memory into the short message database.
In the embodiment of the present invention, it may be determined whether the value of the restoring variable mPosition is greater than or equal to the total number mCount of short messages in the short message backup file.
If yes, the short messages in the short message backup file are completely written into the short message database, and the restoring operation is finished.
If not, determining that the short messages in the short message backup file are not completely written into the short message database, and continuing to execute the restoring operation.
It should be noted that, for simplicity of description, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will recognize that the present invention is not limited by the illustrated order of acts, as some steps may occur in other orders or concurrently in accordance with the embodiments of the present invention. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 7, a block diagram of a structure of an embodiment of a short message recovery apparatus according to the present invention is shown, and the apparatus may specifically include the following modules:
a short message backup file obtaining module 701, configured to obtain a short message backup file to be restored in the mobile terminal;
the multiple storage module 702 is configured to write the short message in the short message backup file into the memory at least twice, and write the short message into the short message database from the memory at least twice.
In one embodiment of the present invention, the multiple storage module 702 comprises:
a part of short message reading sub-module, which is used for reading part of short messages from the short message backup file;
the memory storage submodule is used for storing the partial short messages to a memory;
the short message database writing submodule is used for writing the part of the short messages stored in the memory into the short message database;
the storage completion judging submodule is used for judging whether all the short messages in the short message backup file are written into the short message database; if yes, the storage ending sub-module is called, and if not, the part of short message reading sub-module is returned to be called;
and calling the storage ending submodule to end writing the short message stored in the memory into the short message database.
In an embodiment of the present invention, the partial short message reading sub-module includes:
a handle position reading unit for reading the value of the position variable to obtain a handle position;
a backup data reading unit, configured to read a segment of backup data from the short message backup file from the handle position;
an end identifier recognition unit for recognizing an end identifier of the short message in the backup data;
a data segment dividing unit, configured to divide the backup data into data segments as short messages by using the end identifier as a node;
and the handle position updating unit is used for writing the handle position of the backup data into the position variable.
In an embodiment of the present invention, the partial short message reading sub-module further includes:
a remaining data segment extracting unit, configured to extract, from the data variable, a data segment remaining when the short message was last divided;
the data segment splicing unit is used for splicing the last residual data segment before the first data segment to obtain a complete data segment;
and/or the presence of a gas in the gas,
and the residual data segment storage unit is used for storing the last data segment into the data variable when the last data segment does not have the ending identifier.
In an embodiment of the present invention, the partial short message reading sub-module further includes:
a length recording unit for recording the length of the backup data;
and the short message reading ending backup unit is used for ending reading of part of the short messages from the short message backup file when the length is zero.
In an embodiment of the present invention, the memory storage submodule includes:
the array setting unit is used for setting an array in the memory;
and the array writing unit is used for writing the partial short messages into the array.
In an embodiment of the present invention, the short message database writing sub-module includes:
a variable value configuration unit, configured to configure an initial variable and a final variable, where the value of the initial variable is a ranking of a first short message in the array in all short messages, and the value of the final variable is a ranking of a short message next to a last short message in the array in all short messages;
the assignment module is used for assigning the value of the initial variable to a reduction variable;
the terminal variable judging unit is used for judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable; if yes, calling a short message database writing finishing unit, and if not, calling a short message reading unit;
the short message writing finishing database unit is used for finishing writing the part of the short messages stored in the memory into the short message database;
the short message restoration unit is used for writing the short messages positioned in the restoration variables in the array into a short message database;
and the reduction variable value changing unit is used for adding one to the value of the reduction variable and returning to call the traversal end judgment submodule.
In an embodiment of the present invention, the storage completion determining sub-module includes:
the short message total number judging unit is used for judging whether the value of the restoring variable is larger than or equal to the total number of short messages in the short message backup file; if yes, calling a first confirmation unit, and if not, calling a second confirmation unit;
the first confirming unit is used for confirming that all the short messages in the short message backup file are written into the short message database;
and the second confirming unit is used for confirming that the short messages in the short message backup file are not completely written into the short message database.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, apparatus, or computer program product. Accordingly, embodiments of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, embodiments of the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
Embodiments of the present invention are described with reference to flowchart illustrations and/or block diagrams of methods, terminal devices (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing terminal to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing terminal, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing terminal to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing terminal to cause a series of operational steps to be performed on the computer or other programmable terminal to produce a computer implemented process such that the instructions which execute on the computer or other programmable terminal provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications of these embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the embodiments of the invention.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or terminal that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or terminal. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or terminal that comprises the element.
The method for restoring the short message and the device for restoring the short message provided by the invention are described in detail, a specific example is applied in the text to explain the principle and the implementation mode of the invention, and the description of the embodiment is only used for helping to understand the method and the core idea of the invention; meanwhile, for a person skilled in the art, according to the idea of the present invention, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present invention.
Claims (7)
1. A short message recovery method is characterized by comprising the following steps:
acquiring a short message backup file to be restored in a mobile terminal;
writing the short messages in the short message backup file into a memory at least twice, and writing the short messages into a short message database from the memory at least twice;
the step of writing the short message in the short message backup file into the memory at least twice and writing the short message in the short message backup file into the short message database at least twice from the memory comprises the following steps:
reading part of short messages from the short message backup file;
storing the part of the short messages to a memory;
writing the part of the short messages stored in the memory into a short message database;
judging whether all the short messages in the short message backup file are written into the short message database;
if yes, finishing writing the short message stored in the memory into the short message database;
if not, returning to the step of reading part of the short messages from the short message backup file;
wherein, the step of reading part of the short messages from the short message backup file comprises the following steps:
reading the value of the position variable to obtain a handle position;
reading a section of backup data from the short message backup file from the handle position;
identifying an ending identifier of the short message in the backup data;
dividing the backup data into data segments as short messages by taking the ending identifier as a node;
and writing the handle position of the backup data into the position variable.
2. The method of claim 1, wherein the step of reading the portion of the short message from the short message backup file further comprises:
extracting the remaining data segments when the short message is divided last time from the data variable;
splicing the last residual data segment before the first data segment to obtain a complete data segment;
and/or the presence of a gas in the gas,
and when the last data segment does not have the ending identifier, storing the last data segment into the data variable.
3. The method of claim 1, wherein the step of reading the portion of the short message from the short message backup file further comprises:
recording the length of the backup data;
and when the length is zero, finishing reading part of the short messages from the short message backup file.
4. The method as claimed in claim 1, 2 or 3, wherein the step of storing the portion of the short message in the memory comprises:
setting an array in a memory;
and writing the part of the short message into the array.
5. The method according to claim 4, wherein the step of writing the portion of short messages stored in the memory into a short message database comprises:
configuring an initial variable and a final variable, wherein the value of the initial variable is the sequence of the first short message in the array in all short messages, and the value of the final variable is the sequence of the short message next to the last short message in the array in all short messages;
assigning a value of the initial variable to a reducing variable;
judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable;
if yes, finishing writing the part of the short messages stored in the memory into the short message database;
if not, writing the short message positioned in the reduction variable in the array into a short message database;
and adding one to the value of the reduction variable, and returning to execute the step of judging whether the value of the reduction variable is greater than or equal to the value of the terminal variable.
6. The method as claimed in claim 5, wherein the step of determining whether all the short messages in the short message backup file are written into the short message database comprises:
judging whether the value of the reduction variable is larger than or equal to the total number of short messages in the short message backup file;
if yes, determining that all the short messages in the short message backup file are written into the short message database;
if not, determining that the short messages in the short message backup file are not completely written into the short message database.
7. A short message recovery device, comprising:
the short message backup file acquisition module is used for acquiring a short message backup file to be restored in the mobile terminal;
the multi-time storage module is used for writing the short messages in the short message backup file into the memory at least twice and writing the short messages into the short message database from the memory at least twice;
wherein the multi-time storage module comprises:
a part of short message reading sub-module, which is used for reading part of short messages from the short message backup file;
the memory storage submodule is used for storing the partial short messages to a memory;
the short message database writing submodule is used for writing the part of the short messages stored in the memory into the short message database;
the short message storage completion submodule is used for judging whether all the short messages in the short message backup file are written into the short message database; if yes, the storage ending sub-module is called, and if not, the part of short message reading sub-module is returned to be called;
calling a storage ending submodule for ending writing the short message stored in the memory into the short message database;
wherein, the part of short message reading sub-module comprises:
a handle position reading unit for reading the value of the position variable to obtain a handle position;
a backup data reading unit, configured to read a segment of backup data from the short message backup file from the handle position;
an end identifier recognition unit for recognizing an end identifier of the short message in the backup data;
a data segment dividing unit, configured to divide the backup data into data segments as short messages by using the end identifier as a node;
and the handle position updating unit is used for writing the handle position of the backup data into the position variable.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611058986.3A CN106681859B (en) | 2016-11-25 | 2016-11-25 | Short message recovery method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611058986.3A CN106681859B (en) | 2016-11-25 | 2016-11-25 | Short message recovery method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106681859A CN106681859A (en) | 2017-05-17 |
CN106681859B true CN106681859B (en) | 2021-01-22 |
Family
ID=58866740
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611058986.3A Active CN106681859B (en) | 2016-11-25 | 2016-11-25 | Short message recovery method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106681859B (en) |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101216791A (en) * | 2008-01-04 | 2008-07-09 | 华中科技大学 | File backup method based on fingerprint |
CN101477487A (en) * | 2009-01-22 | 2009-07-08 | 上海交通大学 | Multiple incremental files backup and recovery method |
CN102236586A (en) * | 2010-04-21 | 2011-11-09 | 雷州 | Local and network multiple incremental data backup and recovery method of computer |
CN104050059A (en) * | 2014-06-30 | 2014-09-17 | 珠海市君天电子科技有限公司 | Method and system for data backup and recovery |
CN105138581A (en) * | 2015-07-31 | 2015-12-09 | 北京无线天利移动信息技术股份有限公司 | Mobile information writing and reading method and system |
-
2016
- 2016-11-25 CN CN201611058986.3A patent/CN106681859B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101216791A (en) * | 2008-01-04 | 2008-07-09 | 华中科技大学 | File backup method based on fingerprint |
CN101477487A (en) * | 2009-01-22 | 2009-07-08 | 上海交通大学 | Multiple incremental files backup and recovery method |
CN102236586A (en) * | 2010-04-21 | 2011-11-09 | 雷州 | Local and network multiple incremental data backup and recovery method of computer |
CN104050059A (en) * | 2014-06-30 | 2014-09-17 | 珠海市君天电子科技有限公司 | Method and system for data backup and recovery |
CN105138581A (en) * | 2015-07-31 | 2015-12-09 | 北京无线天利移动信息技术股份有限公司 | Mobile information writing and reading method and system |
Also Published As
Publication number | Publication date |
---|---|
CN106681859A (en) | 2017-05-17 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103235685B (en) | A kind of method and apparatus that terminal operating system desktop contents is set | |
CN103383628A (en) | Method and device for changing icon | |
JP2017531849A (en) | Character editing method and apparatus for screen display device | |
CN107580032B (en) | Data processing method, device and equipment | |
CN110022315A (en) | Weight management method, device and equipment in a kind of piece of chain type account book | |
US20140045467A1 (en) | Method and apparatus for recording information during a call | |
CN111708557A (en) | Method, device and storage medium for updating configuration file | |
CN113282580A (en) | Method, storage medium and server for executing timed task | |
CN108037932B (en) | SPI-NAND configuration file acquisition method and device | |
CN105260085A (en) | Application setting method and terminal utilizing same | |
CN104424125A (en) | Clearing method for mobile terminal cache, device and mobile terminal | |
CN109933742A (en) | Content of pages rearranges a volume method and device in a kind of process | |
CN106681859B (en) | Short message recovery method and device | |
CN105227441A (en) | Cloud server, contact identity defining method and system | |
CN111443945B (en) | Component code modification method and device | |
CN109460193B (en) | IO processing method, device and terminal in storage system | |
CN110059088A (en) | Data attribute identification method, device and equipment in a kind of piece of chain type account book | |
CN111444197B (en) | Verification method, device and equipment for data records in block chain type account book | |
CN108089941A (en) | A kind of backup of terminal data, restoring method and device | |
CN105867961A (en) | System upgrading and degrading method and device | |
CN110795388A (en) | Binary file processing method, system, equipment and readable storage medium | |
CN101534336A (en) | Mobile phone card for supporting quick read | |
CN111858158A (en) | Data processing method and device and electronic equipment | |
CN112579117A (en) | Data upgrading method and device | |
CN111050311A (en) | Data management method, device, storage medium and terminal |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CP01 | Change in the name or title of a patent holder |
Address after: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11 Patentee after: Qingdao Hisense Mobile Communication Technology Co.,Ltd. Address before: 266071 Shandong city of Qingdao province Jiangxi City Road No. 11 Patentee before: HISENSE MOBILE COMMUNICATIONS TECHNOLOGY Co.,Ltd. |
|
CP01 | Change in the name or title of a patent holder |