CN120179620A - Collection operation method, device, equipment and storage medium - Google Patents
Collection operation method, device, equipment and storage medium Download PDFInfo
- Publication number
- CN120179620A CN120179620A CN202510155813.6A CN202510155813A CN120179620A CN 120179620 A CN120179620 A CN 120179620A CN 202510155813 A CN202510155813 A CN 202510155813A CN 120179620 A CN120179620 A CN 120179620A
- Authority
- CN
- China
- Prior art keywords
- data table
- collection
- identifier
- media
- file
- 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.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/14—Details of searching files based on file metadata
- G06F16/148—File search processing
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/10—File systems; File servers
- G06F16/16—File or folder operations, e.g. details of user interfaces specifically adapted to file systems
- G06F16/168—Details of user interfaces specifically adapted to file systems, e.g. browsing and visualisation, 2d or 3d GUIs
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Human Computer Interaction (AREA)
- Library & Information Science (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The application relates to a collection operation method, a device, equipment and a storage medium, wherein the method comprises the steps of receiving a collection operation instruction of a media database, wherein the collection operation instruction at least comprises a file identifier and a data table identifier; determining a data table to be operated in a media database according to the data table identifier, wherein the media database comprises a media data table and a collection data table; and executing the operation corresponding to the collection operation instruction in the data table to be operated according to the file identification. Therefore, when the collection operation instruction is received, the method can execute the operation corresponding to the instruction aiming at the data table to be operated, and further realize the collection operation on the media file.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a collection operation method, apparatus, device, and storage medium.
Background
With the development of technology, photo albums are used more and more frequently. The album is provided with a media database for managing and storing media files, recording and indexing information related to the media files stored on the device, such as file name, path, size, date, etc.
In the album showing process, related information of the media file needs to be called from the media database and presented. In order to improve the convenience of searching data for users, the album can be additionally provided with a collection function, so that users can quickly browse frequently-viewed media files by means of the function. Therefore, there is an urgent need to design an effective collection operation method for an album.
Disclosure of Invention
The application provides a collection operation method, a collection operation device, equipment and a storage medium, wherein when a collection operation instruction is received, the operation corresponding to the instruction can be executed aiming at the data table to be operated, and further the collection operation is realized on the media file.
In a first aspect, the present application provides a method of collection operation, the method comprising:
receiving a collection operation instruction of a media database, wherein the collection operation instruction at least comprises a file identifier and a data table identifier;
determining a data table to be operated in a media database according to the data table identifier, wherein the media database comprises a media data table and a collection data table;
and executing the operation corresponding to the collection operation instruction in the data table to be operated according to the file identification.
Optionally, in the case that the collection operation instruction is a collection deletion instruction, the data table identifier is an identifier of a media data table, and determining, in a media database, a data table to be operated according to the data table identifier includes:
Searching the collection data table according to the file identification to obtain a searching result;
Under the condition that the search result is a preset result, determining the media data table and the collection data table as data tables to be operated, wherein the preset result is that the collection data table has the file identification;
And under the condition that the search result is not a preset result, determining the media data table as a data table to be operated.
Optionally, when the collection operation instruction is a collection cancellation instruction, executing, in the to-be-operated data table, an operation corresponding to the collection operation instruction according to the file identifier, including:
Searching a corresponding collection identifier in the media data table according to the file identifier under the condition that the data table identifier is the identifier of the media data table, and executing deleting operation on the collection identifier;
And searching corresponding collection data in the collection data table according to the file identification under the condition that the data table identification is the identification of the collection data table, and executing deleting operation on the collection data.
Optionally, when the collection operation instruction is a collection adding instruction, executing, in the to-be-operated data table, an operation corresponding to the collection operation instruction according to the file identifier, including:
under the condition that the data table identifier is the identifier of the media data table, determining a collection identifier adding position corresponding to the file identifier in the media data table according to the file identifier, and adding the collection identifier into the collection identifier adding position;
and under the condition that the data table identifier is the identifier of the collection data table, determining associated data corresponding to the file identifier in the media data table according to the file identifier, determining collection data according to the associated data, and adding the collection data into the collection data table.
Optionally, when the collection operation instruction is a collection query instruction, executing, in the to-be-operated data table, an operation corresponding to the collection operation instruction according to the file identifier, including:
under the condition that the data table identifier is the identifier of the media data table, inquiring whether a collection identifier corresponding to the file identifier exists in the media data table to obtain an inquiring result;
Under the condition that the data table identifier is the identifier of the collection data table, inquiring whether collection data corresponding to the file identifier exists in the collection data table, and obtaining an inquiring result;
And displaying a corresponding operation interface according to the query result.
Optionally, the collection operation instruction further includes a user ID, and searching corresponding collection data in the collection data table according to the file identifier includes:
And determining corresponding collection data in the collection data table according to the file identification and the user ID.
Optionally, the executing, in the to-be-operated data table, the operation corresponding to the collection operation instruction according to the file identifier includes:
Determining a sub-data table corresponding to the type in the data table to be operated according to the type of the file identifier;
and executing the operation corresponding to the collection operation instruction in the sub-data table according to the file identification.
In a second aspect, the present application provides a stowage operating device, the device comprising:
The receiving unit is used for receiving collection operation instructions of the media database, wherein the collection operation instructions at least comprise file identifications and data table identifications;
The determining unit is used for determining a data table to be operated in a media database according to the data table identifier, wherein the media database comprises a media data table and a collection data table;
And the operation unit is used for executing the operation corresponding to the collection operation instruction in the data table to be operated according to the file identification.
Optionally, in the case that the collection operation instruction is a collection deletion instruction, the data table identifier is an identifier of a media data table, and the determining unit is configured to:
Searching the collection data table according to the file identification to obtain a searching result;
Under the condition that the search result is a preset result, determining the media data table and the collection data table as data tables to be operated, wherein the preset result is that the collection data table has the file identification;
And under the condition that the search result is not a preset result, determining the media data table as a data table to be operated.
Optionally, in the case where the collection operation instruction is a collection cancellation instruction, the operation unit is configured to:
Searching a corresponding collection identifier in the media data table according to the file identifier under the condition that the data table identifier is the identifier of the media data table, and executing deleting operation on the collection identifier;
And searching corresponding collection data in the collection data table according to the file identification under the condition that the data table identification is the identification of the collection data table, and executing deleting operation on the collection data.
Optionally, in the case that the collection operation instruction is a collection adding instruction, the operation unit is configured to:
under the condition that the data table identifier is the identifier of the media data table, determining a collection identifier adding position corresponding to the file identifier in the media data table according to the file identifier, and adding the collection identifier into the collection identifier adding position;
and under the condition that the data table identifier is the identifier of the collection data table, determining associated data corresponding to the file identifier in the media data table according to the file identifier, determining collection data according to the associated data, and adding the collection data into the collection data table.
Optionally, in the case that the collection operation instruction is a collection query instruction, the operation unit is configured to:
under the condition that the data table identifier is the identifier of the media data table, inquiring whether a collection identifier corresponding to the file identifier exists in the media data table to obtain an inquiring result;
Under the condition that the data table identifier is the identifier of the collection data table, inquiring whether collection data corresponding to the file identifier exists in the collection data table, and obtaining an inquiring result;
And displaying a corresponding operation interface according to the query result.
Optionally, the collection operation instruction further comprises a user ID, and the operation unit is used for:
And determining corresponding collection data in the collection data table according to the file identification and the user ID.
Optionally, the operation unit is configured to:
Determining a sub-data table corresponding to the type in the data table to be operated according to the type of the file identifier;
and executing the operation corresponding to the collection operation instruction in the sub-data table according to the file identification.
In a third aspect, the present application provides a favorite operating device comprising at least one communication interface, at least one bus connected to the at least one communication interface, at least one processor connected to the at least one bus, at least one memory connected to the at least one bus, wherein the processor is configured to:
receiving a collection operation instruction of a media database, wherein the collection operation instruction at least comprises a file identifier and a data table identifier;
determining a data table to be operated in a media database according to the data table identifier, wherein the media database comprises a media data table and a collection data table;
and executing the operation corresponding to the collection operation instruction in the data table to be operated according to the file identification.
In a fourth aspect, the present application provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the above-described method of collecting operations.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the advantages that in the embodiment of the application, the collection operation instruction of the media database is received, the collection operation instruction at least comprises a file identifier and a data table identifier, the data table to be operated is determined in the media database according to the data table identifier, the media database comprises the media data table and the collection data table, and the corresponding operation of the collection operation instruction is executed in the data table to be operated according to the file identifier. Therefore, when the collection operation instruction is received, the embodiment of the application can execute the operation corresponding to the instruction aiming at the data table to be operated, thereby realizing the collection operation on the media file.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the invention or the technical solutions of the prior art, the drawings which are used in the description of the embodiments or the prior art will be briefly described, and it will be obvious to a person skilled in the art that other drawings can be obtained from these drawings without inventive effort.
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which the figures of the drawings are not to be taken in a limiting sense, unless otherwise indicated.
FIG. 1 is a schematic diagram of a relationship of a kind provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of a relationship between classes according to an embodiment of the present application;
FIG. 3 is a flowchart illustrating a collection operation method according to an embodiment of the present application
Fig. 4 is a schematic flow chart of a method for deleting based on a data table according to an embodiment of the present application;
FIG. 5 is a flowchart illustrating a method for executing a collection cancellation instruction according to an embodiment of the present application;
FIG. 6 is a flowchart illustrating a method for executing a collection add instruction according to an embodiment of the present application;
FIG. 7 is a flowchart illustrating a method for executing a collection query instruction according to an embodiment of the present application;
FIG. 8 is a flowchart illustrating another data manipulation method according to an embodiment of the present application;
FIG. 9 is a flowchart illustrating a data manipulation method according to an embodiment of the present application;
FIG. 10 is a request timing diagram of yet another APP provided by an embodiment of the present application;
FIG. 11 is a schematic flow chart of a collection operation device according to an embodiment of the present application;
Fig. 12 is a schematic diagram of a collection operation device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The following disclosure provides many different embodiments, or examples, for implementing different structures of the invention. In order to simplify the present disclosure, components and arrangements of specific examples are described below. They are, of course, merely examples and are not intended to limit the invention. Furthermore, the present invention may repeat reference numerals and/or letters in the various examples. This repetition is for the purpose of simplicity and clarity and does not in itself dictate a relationship between the various embodiments and/or configurations discussed.
Firstly, the application is explained that the Android media provider (Android Media Provider) is an important component for managing media files and related information in the Android system. The Android database assistant (Android DataBaseHelper) is a class used for assisting in managing a database in Android development, is generally responsible for creating the database, executing initialization operations such as table building and the like, and provides basic operation methods such as adding, deleting, modifying and checking the database, and development and maintenance work related to the database can be more conveniently carried out by using DataBaseHelper. MediaStore of Android is a class for interacting with Media databases, providing a series of methods to obtain information of Media files, perform operations on Media files (e.g., insert, delete, etc.), and can synchronize with Media Provider.
Secondly, before implementing the embodiment of the present application, since the media data table already exists in the media database, only the collection data table needs to be created in the media database, wherein key fields in the collection data table are shown in table 1, and part of fields in the media data table are shown in table 2.
TABLE 1
Field name | Data type | Description of the invention |
id | Self-increasing integer | Unique identification of collection records |
user_id | Character string | User id |
_data | Character string | Picture or video storage path |
mime_type | Character string | Picture or video type |
date_added | Date and time | Time of addition to database |
TABLE 2
The specific step of creating table 1 is to define a createFavoritesTable method in MediaProvider classes, which can create a collection data table through sql statement, and the field names in the collection data table are the field names included in table 1. Meanwhile, the definition of the newly added field of the collection data table can be added in the system MediaStore class, specifically, an interface FavoritesColumns is newly added in the system source code MediaStore class, and the interface can realize an interface MediaColumns. Fields within the collection data table, i.e., fields in table 1, are defined within this interface.
The above FavoritesColumns interface defines the field format as follows, referring to the table field definition in the current native system.
For example:
@Column(value=Cursor.FIELD_TYPE_INTEGER,readOnly=
true);
public static final String BUCKET_ID="bucket_id";
@Column(value=Cursor.FIELD_TYPE_STRING)
public static final String USER_ID="user_id";
Since other fields id, data, mime_type, data_add in table 1 are already defined fields of the existing system used, and therefore are already contained in the MediaColumns interface, the repeated definition in the FavoritesColumns interface is not required.
Implementation of newly adding one Favorites class in MediaStore classes
FavoritesColumns interface, defining a constant EXTERNAL _content_uri= "// media/external/Favorites" in the Favorites class, where this constant URI will be used in the MediaProvider method to represent the identity of the collection data table to be created next, this URI is a flag of the collection data table exposed to the outside, and when this URI is used, the data table to be operated is the collection data table. At the same time, an Int constant type FAVORITE is defined, which is used to return the constant when the external incoming Uri is fetched in MediaProvider class and matched with the Uri of the collection data table, and then to perform the corresponding operation on the collection data table.
In updateDatabase interface method in DataBaseHelper class, it can be determined that the version number of the database of the current system is smaller than the latest version number, if so, the data of the current system needs to be updated, and the data is called during the update
CreateFavoritesTable method, and further creating a collection data table.
Specifically, the embodiment of the application provides a relation diagram of related classes, which is shown in fig. 1, and includes a MediaStore class (media storage class), mediaColumns class (media column class) and FavoritesColumns class (collection column class), baseColumns class (base column class), and Favorites class (collection class) in MediaStore class. Wherein MediaStore is a class in a system frame, is a core class of related operation of a media database, provides an interface for accessing and operating media file information, and is closely related to bottom data interaction of functions such as album display and collection. The MediaStore class includes three fields, an authentification_uri field (authorized uniform resource identifier field) for identifying information, an ACTION string action_view field (VIEW ACTION field) for defining an operation of viewing a media file, and a volume_interface field (INTERNAL VOLUME field) for representing content storage VOLUME related information, respectively. The MediaStore class also includes two methods, a getVersion method for acquiring version information of the media database (acquire version method) and a getMediaUri method for acquiring uniform resource identifiers (acquire authorized uniform resource identifier method), respectively. The MediaColumns class inherits from the BaseColumns class for defining generic column information related to the media file. The MediaColumns class includes three fields, which are a DATA field (DATA field) storing the actual path of the media file, a mime_type field (multipurpose internet mail extension TYPE field) for identifying the file format, and a date_add field (add DATE field) representing time information, respectively. The FavoritesColumns class inherits from MediaColumns for processing data stores related to favorites functions. It includes a USER ID field (USER number field) for recording the USER ID that favorites the media file. The BaseColumns class serves as a basic class and provides basic field definition for other data column related classes, and comprises two fields, namely an ID field (number field) for recording the media file in a database and a COUNT field (COUNT field) for indicating the number of records. The Favorites class inherits from
FavoritesColumns, which is used to represent collection-related entity classes, includes EXTERNAL _content_uri field (external CONTENT uniform resource identifier field) for storing external CONTENT URIs corresponding to collection media files.
Meanwhile, the embodiment of the application provides a relation diagram of related classes, which is shown in fig. 2, and comprises MediaProvider classes (media provider class), contentProvider class, dataBaseHelper classes (database help class) and sqliteompler class (database help class). The MediaProvider class inherits from the ContentProvider class and is used for processing the requests of the external application for adding, deleting, modifying and searching the media data, and comprises two fields, namely a character string constant FAVORITE field (collection field) for identifying operations or data types related to collection and a mUriMatcher field (URI matcher field) for matching different URI requests. The MediaProvider class also includes four methods, onUpgrade method for updating the database structure (upgrade method), onCreateInternal method for initializing operations (internal creation method), queryInternal method for querying media file related data (internal query method), and createFavoritesTable method for creating a collection table (query file method), respectively. The ContentProvider class defines a set of standard interfaces through which other applications can access and manipulate their managed data, including mContext fields (context fields) holding the application context. Also included are a plurality of methods, respectively, onCreate method (creation method) for initializing a resource, onDowngrade method (demotion method) for executing at the time of database promotion, onUpgrade method (promotion method) for executing at the time of database promotion, insert method (insertion method) for inserting a data record, query method (query method) for querying a data record, delete method (deletion method) for deleting a data record, and update method (update method) for updating a data record. The DataBaseHelper class, as an internal class of MediaProvider, inherits from the sqliteon helper and is responsible for managing the creation, opening and version management of the SQLite database. It encapsulates the operational details associated with the database and provides a simple interface for MediaProvider to operate the database. It includes mName fields (name fields) for storing the names of the databases. Also included are methods, specifically onCreate methods (creation methods) that are invoked when the database is first created, onUpgrade methods (promotion methods) that are invoked when the database is promoted, and onDowngrade methods (demotion methods) that are invoked when the database is reduced. The SQLiteOpenHelper class is an abstract class in the Android framework and is used for managing the creation and version management of the SQLite database. the class includes mDataBase fields (database fields) through which specific SQL statements are executed. The class also includes methods including, in particular, a query method (query method) for polling data records, an insert method (insert method) for inserting data records, a delete method (delete method) for deleting data records, and an update method (update method) for updating data records.
Based on the original media data table and the newly built collection data table in the database, the embodiment of the application provides a collection operation method, which only needs to manage one database, reduces the difficulty of managing the database, further reduces the time for managing the database, and comprises the following specific steps:
Step 301, a collection operation instruction of a media database is received.
The collection operation instruction is an operation instruction related to collection, and specifically comprises a collection inquiry instruction, a collection cancellation instruction, a collection deletion instruction and a collection addition instruction. The collection inquiry instruction is used for inquiring whether the media file is collected, the collection cancellation instruction is used for canceling the collection of the media file, the collection deletion instruction is used for deleting the collection file, and the collection addition instruction is used for collecting the media file. The collection operation instruction at least carries a file identifier and a data table identifier of the media file. The media file may be a picture or a video, which is not limited herein. The data table identifier is an identifier that uniquely indicates the data table, and may be a URI, or may be other data, which is not limited herein. The media database includes a media data table and a collection data table.
Specifically, the application provides an application scene, when a user opens a media client, a media file list can be displayed based on media files in a media database, and the media client can display locally stored media files and can also perform operations related to collection on the media files. When a user can click on a certain media file in the media file list, the media client receives a file display instruction of the media file, wherein the file display instruction carries a file identification of the media file. And then, finding out the corresponding media file in the stored media files according to the file identification in the file display instruction, and displaying the media file.
Meanwhile, the user can trigger a collection inquiry command by pressing a certain media file for a long time, and further, a corresponding collection operation list is displayed according to the inquiry result of the collection inquiry command. Specifically, when the media client receives a collection inquiry command of a certain media file, a data table identifier and a file identifier in the collection inquiry command are obtained, whether the media file corresponding to the file identifier is collected or not is inquired in a data table indicated by the data table identifier according to the file identifier, if so, a displayed collection operation list comprises a collection cancel button and a collection delete button, and if not, a displayed collection operation list comprises a collection adding button.
When the user clicks the collection cancel button, the media client receives a collection cancel instruction corresponding to the button, and then cancels the collection of the media file according to the collection cancel instruction. When the user clicks the collection deleting button, the media client receives a collection deleting instruction corresponding to the button, and then deletes the media file according to the collection deleting instruction. When the user clicks the collection adding button, the media client receives a collection adding instruction corresponding to the button, and then adds the media file according to the collection adding instruction.
Before the data table identifier is acquired, it is also necessary to detect whether the user ID is acquired, and when the user ID is not acquired, it is necessary to operate the media data table, so that the identifier of the media data table and the file identifier of the media file are acquired, and a collection operation instruction is generated. When the user ID is acquired, the operation of the collection data table is required, so that the identification of the collection data table and the file identification of the media file are acquired, and a collection operation instruction is generated.
Step 302, determining a data table to be operated in the media database according to the data table identification.
The data table to be operated can be a media data table or a collection data table. The media data table is used for storing associated data of the media file, such as file identification, collection identification, operation date and the like of the media file. The collection data table is used for storing collection data of each account, and the collection data at least comprises a user ID and a file identification. The file identification may uniquely indicate an identification of the media file, e.g., a storage path of the media file. The collection identifier is used for indicating that the corresponding media file is collected and is a unique identifier for indicating collection. The identifier of the collection data table is the exposed URI, and the identifier of the media data table can be the URI or other identifiers uniquely indicating the media data table.
In this step, the identification in the collection operation instruction is compared with the identification of each data table to find the data table to be operated. When the comparison is made, the data table on the comparison is determined as the data table to be operated.
In practice, when the collection operation instruction is a collection cancellation instruction, a collection addition instruction or a collection inquiry instruction, the collection operation instruction only needs to change the collection data and does not need to delete all associated data, so that the data table to be operated is only determined according to the data table identifier, and then the related operation is carried out on the data table to be operated. Specifically, when the media client is not logged in, the data table identifier in the collection operation instruction is the identifier of the media data table, so that only related operations need to be performed on the media data table. When the media client is logged in, the data table identifier in the collection operation instruction is the collection data table identifier, so that the collection data table is only required to be subjected to related operation.
When the collection operation instruction is a collection deletion instruction, the data table identifier in the collection deletion instruction is the identifier of the media data table no matter whether the media client is logged in or not. This is because the collection deletion instruction deletes a collection file, and therefore, when deleting a collection file, all associated data of the collection file needs to be deleted. In practice, the associated data of the collection file must be stored in the media data table, so that the media data table needs to be acquired in the media database, and then the associated data of the collection file is acquired in the media data table according to the file identifier in the collection deletion instruction, and the associated data is deleted. Of course, the collection data table may or may not store the collection data of the collection file. Therefore, it is also necessary to obtain a collection data table from the media database, detect the collection data table according to the file identifier, and delete the collection data when the collection data corresponding to the file identifier is detected.
Based on the above, in the case where the collection operation instruction is a collection deletion instruction, it is necessary to use the file identifier to detect the collection data table to determine whether or not a deletion operation is required to be performed on the collection data table. When the deletion operation is needed to be performed on the collection data table, the collection data table and the media data table are determined to be the data table to be operated, and when the deletion operation is not needed to be performed on the collection data table, the media data table is only determined to be the data table to be operated.
Or in the case where the collection operation instruction is a collection deletion instruction, if the media client is logged in, the collection operation instruction may further include a user ID for indicating that a deletion operation is performed on the collection data table.
Step 303, executing the operation corresponding to the collection operation instruction according to the file identification and the data table to be operated.
In this step, when the data table to be operated is a media data table, a corresponding operation is performed on the media data table according to the file identification, and when the data table to be operated is a collection data table, a corresponding operation is performed on the collection data table according to the file identification.
In the embodiment of the application, a collection operation instruction of a media database is received, wherein the collection operation instruction at least comprises a file identifier and a data table identifier, a data table to be operated is determined in the media database according to the data table identifier, the media database comprises the media data table and the collection data table, and the collection operation instruction is executed in the data table to be operated according to the file identifier. Therefore, when the collection operation instruction is received, the embodiment of the application can execute the operation corresponding to the instruction aiming at the data table to be operated, thereby realizing the collection operation on the media file.
Meanwhile, in the related art, because the media database does not have an account collection function, a common practice is to newly build a database in an album and newly build a collection data table in the database, wherein the collection data table is used for storing user accounts and collected media files. However, based on the above method, two databases need to be managed, and the problems of architecture difference, authority difference, compatibility problem, data synchronization and the like of the two databases all increase the management difficulty of the databases, which is time-consuming and laborious. The collection data table and the media data table are arranged in the media database, so that only one database needs to be managed, the difficulty of managing the database is reduced, and the time for managing the database is further shortened.
In the embodiment of the application, under the condition that the collection operation instruction is a collection deletion instruction, whether to execute deletion operation on the collection data table is detected according to the file identification, when the deletion operation is executed on the collection data table, the deletion operation is executed on the media data table and the collection data table according to the file identification, and when the deletion operation is not executed on the collection data table, the deletion operation is executed on the collection data table according to the file identification. Accordingly, an embodiment of the present application provides a method for deleting data based on a data table, where the method is shown in fig. 4, and further defines step 302, and the specific steps include:
step 401, searching the collection data table according to the file identification to obtain a searching result.
Wherein the file identity may be an identity for uniquely indicating the media file. For example, when deleting a media file, a file path of the media file needs to be acquired, and then the media file is searched based on the file path, so the file path can be used as a file identifier.
In the step, the file identifications in the collection deleting instruction are compared with all the file identifications in the collection data table one by one, when the comparison is carried out, the file identifications in the collection data table are determined to exist, and when the comparison is not carried out, the file identifications in the collection data table are determined to not exist.
In step 402, in case that the search result is a preset result, the media data table and the collection data table are determined as the data table to be operated.
The preset result is that the collection data table has file identification.
In this step, when the search result is the preset result, it is indicated that the file identifier in the collection deletion instruction exists in the collection data table, and the collection data table needs to be operated, so that the media data table and the collection data table are determined as the data table to be operated.
Step 403, determining the media data table as the data table to be operated in case that the search result is not the preset result.
In this step, when the search result is not the preset result, it is indicated that the file identifier in the collection deletion instruction does not exist in the collection data table, and the operation is not required on the collection data table, so that the media data table is determined as the data table to be operated.
And step 404, executing deleting operation on the data table to be operated according to the file identification.
In this step, when the data table to be operated is a collection data table and a media data table, according to the file identifier, searching associated data corresponding to the file identifier in the media data table, performing a deletion operation on the associated data, and according to the file identifier, searching collection data corresponding to the file identifier in the collection data table, and performing a deletion operation on the collection data. When the data table to be operated is only a media data table, according to the file identification, searching associated data corresponding to the file identification in the media data table, and executing deleting operation on the associated data.
In addition, the deletion operation of the collection data table can be directly indicated. To instruct to perform a delete operation on the collection data table, a user ID may also be obtained to instruct to perform a delete operation on the collection data table by the user ID. For example, the data table identity, user ID and file identity are obtained, i.e. URI, user_id and file path are obtained, these parameters are passed into the public final int delete(@RequiresPermission.Write@NonNull Uri url,@Nullable String where,@Nullable String[]selectionArgs) method of ContentResolver, and by this method are called into public INT DELETE (URI, string selection, string [ ] selectionArgs) inside MediaProvider. PRIVATE INT DELETEINTERNAL (Uri, string userWhere, string [ ] userWhereArgs) within this delete method can distinguish between type deletions of the table. Specifically, when deleting a media file, URIs of the incoming media data table, such as
The mediastore. Video. Media. EXTERNal_CONTENT_UR also transmits a user_id, and at the moment, the user_id is transmitted, and the method is moved to DELETEINTERNAL, and then the private int deleteRecursive(SQLiteQueryBuilder qb,SQLiteDatabase db,String userWhere,String[]userWhereArgs) method is called, the deletion operation is executed on the media data table according to the file path, and at the same time, the corresponding collection data in the collection data table is directly deleted according to the user_id and the file path.
Under the condition that the collection operation instruction is a collection cancellation instruction, acquiring a data table to be operated from the media database according to the data table identification, and further executing corresponding operation on the data table to be operated according to the collection cancellation instruction. Therefore, an embodiment of the present application provides a method for executing a collection cancellation instruction, where the method is shown in fig. 5, and the specific steps include:
In step 501, in the case that the data table identifier is the identifier of the media data table, according to the file identifier, searching the corresponding collection identifier in the media data table, and executing a deletion operation on the collection identifier.
In this step, when a certain media file is collected, the media data table has a collection identifier of the media file, and when the media file is canceled, the collection identifier of the media file needs to be deleted. Therefore, when the data table identifier is the identifier of the media data table, the collection identifier corresponding to the file identifier is found in the media data table according to the file identifier, and the deletion operation is performed on the collection identifier.
Step 502, in the case that the data table identifier is the identifier of the collection data table, searching corresponding collection data in the collection data table according to the file identifier, and executing a deletion operation on the collection data.
In this step, when a certain media file is collected, the collection data table stores collection data of the media file, and when the media file is canceled, the collection data of the media file needs to be deleted. And under the condition that the data table identifier is the identifier of the collection data table, searching corresponding collection data in the collection data table according to the file identifier, and executing deleting operation on the collection data.
Furthermore, the user ID of the current account can be obtained, and corresponding collection data is searched in the collection data table according to the user ID and the file identification.
Specifically, the corresponding user_id, the constant EXTERNAL _content_uri in the favorites class defined in the system MediaStrore class, and the path for canceling the collection file need to be transferred to the public final int delete(@RequiresPermission.Write@NonNull Uri url,@Nullable String where,@Nullable String[]selectionArgs) method in the ContentResolver class, and this method will call the delete method in MediaProvider to delete the data table to be operated.
And under the condition that the collection operation instruction is a collection adding instruction, acquiring a data table to be operated from the media database according to the data table identification, and further executing corresponding operation on the data table to be operated according to the collection cancelling instruction. Therefore, an embodiment of the present application provides a method for executing a collection add instruction, where the method is shown in fig. 6, and the specific steps include:
In step 601, when the data table identifier is the identifier of the media data table, according to the file identifier, a collection identifier adding position corresponding to the file identifier is determined in the media data table, and the collection identifier is added to the collection identifier adding position.
In this step, the media data table further includes a collection field name, and the collection identifier addition location is found in the media data table according to the file identifier and the collection field name. And adding the collection identification into the collection identification adding position to indicate the media file corresponding to the collection file identification.
In step 602, when the data table identifier is the identifier of the collection data table, associated data corresponding to the file identifier is determined in the media data table according to the file identifier, the collection data is determined according to the associated data, and the collection data is added to the collection data table.
The collection data and the associated data have overlapping data, the overlapping data can be data such as file identification, and the collection data generally consists of the overlapping data and a user ID.
In this step, field names are obtained from the collection data table, data corresponding to the field names are searched for based on the field names and the associated data, the collection data is composed of the data and the user ID, and the collection data is inserted into the collection data table. Or when the collection data only comprises the user ID and the file identification, the file identification is only required to be obtained in the collection adding instruction, and then the file identification and the user ID are used as the collection data and are inserted into a collection data table.
In actual use, when the media client executes the collection operation, the user ID, the file identification and the identification of the collection data table are passed through the public final@nullable Uri in ContentResolver classes
The insert (@ RequirePermission. Write @ NonNull Uri url, @ Nullable ContentValues values) method, and then into the MediaProvider class, after which the user collection data is inserted into the collection data table.
Specifically, mediaProvider classes are set in the media application, and are used for managing media files and associated data for the media application. In MediaProvider, a public Uriinsert (Uri, contentValues values) interface method is provided, and the method is used for comparing an externally input Uri with a Uri of a data table, determining the data table to be operated, and then inserting data into the data table. The private Uri insertInternal (Uri, contentValues initialValues) method is a sub-method that inherits the method, which can receive the Uri from outside, compare the Uri with the Uri of the collection data table, return a constant FAVORITE when compared, and insert the collection data into the collection data table indicated at FAVORITE.
Where uri is used to represent the data table identification.
And under the condition that the collection operation instruction is a collection inquiry instruction, acquiring a data table to be operated from the media database according to the data table identification, and further executing corresponding operation on the data table to be operated according to the collection cancellation instruction. Therefore, an embodiment of the present application provides a method for executing a collection query instruction, where the method is shown in fig. 7, and the specific steps include:
in step 701, under the condition that the data table identifier is the identifier of the media data table, inquiring whether a collection identifier corresponding to the file identifier exists in the media data table, and obtaining an inquiring result.
In this step, in the case that the data table identifier is the identifier of the media data table, the collection identifier corresponding to the file identifier is searched in the media data table, and when the collection identifier is searched, it is indicated that the media file identified by the file has been collected, so that the query result is that the media file has been collected. When the collection identification is not found, the media file identified by the file identification is not collected, so that the query result is that the media file is not collected.
Step 702, under the condition that the data table identifier is the identifier of the collection data table, inquiring whether collection data corresponding to the file identifier exists in the collection data table, and obtaining an inquiring result.
In this step, in the case that the data table identifier is the identifier of the collection data table, the collection data corresponding to the file identifier is searched in the collection data table, and when the collection data is searched, it is indicated that the media file identified by the file has been collected, so that the query result is that the media file has been collected. When the collection data is not found, the media file identified by the file is not collected, so that the query result is that the media file is not collected.
Further, public Cursor query (Uri, string [ ] project, bundle queryArgs, cancellationSignal signal) interface methods in MediaProvider class represent query data, private Cursor in
queryInternal(Uri uri,String[]projection,Bundle
QueryArgs, cancellationSignal signal) is a type-by-type query (there are many tables in the media library, when data is inserted, it is necessary to determine which database table is to be operated by the currently executed logic through the externally incoming Uri), and the method can compare the externally incoming Uri with the Uri of the collection data table, and when compared, return to FAVORITE. And when the return is FAVORITE, inquiring corresponding collection data in the collection data table according to the user_id and the file identification. Or query the collection data in the collection data table by calling the query method in DataBaseHelper.
In the method for calling the query method, the media client can transmit the user_id and the file identifier as parameters to the public final@Nullable Cursor query(@RequiresPermission.Read@NonNull Uri uri,@Nullable String[]projection,@Nullable String selection,@Nullable String[]selectionArgs,@Nullable String sortOrder) method of ContentResolver, the method corresponds to the query method in MediaProvider, and then the query method is matched with the collection data table through the predefined uri, so that the collection data table is queried.
Step 703, displaying a corresponding operation interface according to the query result.
In this step, when the query result is that the media file is not collected, the displayed operation interface includes a collection adding button, and when the query result is that the media file is collected, the displayed operation interface includes a collection cancelling button and a collection deleting button.
In the embodiment of the application, the sub-data table corresponding to the type can be determined in the data table to be operated according to the type of the file identifier, and then the corresponding operation can be executed on the sub-data table according to the file identifier. Accordingly, an embodiment of the present application provides a data manipulation method, as shown in fig. 8, including the following specific steps:
Step 801, according to the type of the file identifier, determining a sub-data table corresponding to the type in the data table to be operated.
The type of the file identifier is used for indicating whether the corresponding media file is a picture or a video. For example, when the type of the file identifier is a first type, the corresponding media file is a picture, and when the type of the file identifier is a second type, the corresponding media file is a video.
In practice, the file identifiers are often ordered according to the types of the file identifiers, so that the columns where the file identifiers are located are ordered, and then the related data of the file identifiers of the same type are located in a certain area, so that according to the types of the file identifiers, an area corresponding to the types can be determined in the data table to be operated, and the data table corresponding to the area is determined to be a sub-data table.
Step 802, executing corresponding operation on the sub data table according to the file identification.
In this step, according to the file identifier, data corresponding to the file identifier is searched in the sub-data table, and then a related operation is performed on the data.
Further, when the data table to be operated is a collection data table, corresponding data can be searched in the sub data table according to the user ID and the file identifier, and then related operations are executed on the data.
As shown in fig. 9, when the media client detects the collection trigger instruction, the system interface is called to operate on the media database. For example, when a collection adding instruction is received, a system interface is called to perform collection adding operation on the media database. And when receiving the collection inquiry command, calling a system interface to perform collection inquiry operation on the media database. When receiving the collection cancellation instruction, the system interface is called to perform collection cancellation operation on the media database. And then, determining whether the data table to be operated is a media data table or a collection data table, when the data table to be operated is the media data table, performing corresponding operation on the media data table, and when the data table to be operated is the collection data table, performing corresponding operation on the collection data table.
In the implementation of the application, whether the account number is logged in can be detected by detecting whether the user ID is included in the collection operation instruction. And when the account is logged in, determining the data table to be operated as a collection data table, and when the account is not logged in, determining the data to be operated as a media data table. Because the collection operation instruction in the application also carries the data table identifier, the embodiment of the application can also determine the data to be operated according to the data table identifier.
In the embodiment of the application, there is also provided a request timing diagram of an APP, where the request timing diagram is shown in fig. 10, and the specific steps include:
In step 1001, when the media client detects a collection triggering operation, the media client obtains a file identifier of a media file to be operated.
In this step, when the media client detects the collection operation, the media client acquires the file path of the media file to be operated.
Step 1002, call Media Provider to obtain the data table identification.
In this step, an operation method in the Media Provider is called to acquire the URI by the matchURI method in the method.
Step 1003, call DataBaseHelper to make corresponding operation to media database according to file identification and data table identification.
In this step, the file path and URI are passed into the operation method in DataBaseHelper to invoke the system interface to perform the corresponding operation on the media database.
Specifically, when the collection triggering operation is a collection adding operation, a file path of a Media file to be operated is acquired, an insertion method in the Media Provider is called to acquire a URI through a matchURI method in the method, the file path and the URI are transmitted to an insertion method in DataBaseHelper, and a system interface is called to perform the collection adding operation on the database. In addition, an insertion method in the Media Provider may be called to detect whether the user_id is acquired through the matchuser _id method in the method, and further, when the user_id is acquired, the file path, the URI, and the user_id are transferred to the insertion method in DataBaseHelper.
The collection triggering operation is similar to the collection adding operation, except that the collection querying operation also returns the query result to the media client.
As shown in fig. 11, an embodiment of the present application provides a collection operation device, where the device corresponds to an embodiment of a method, and specifically includes:
a receiving unit 1101, configured to receive a collection operation instruction of a media database, where the collection operation instruction includes at least a file identifier and a data table identifier;
A determining unit 1102, configured to determine, according to the data table identifier, a data table to be operated in a media database, where the media database includes a media data table and a collection data table;
and an operation unit 1103, configured to execute, in the to-be-operated data table, an operation corresponding to the collection operation instruction according to the file identifier.
Optionally, in the case where the collection operation instruction is a collection deletion instruction, the data table identifier is an identifier of a media data table, and the determining unit 1102 is configured to:
Searching the collection data table according to the file identification to obtain a searching result;
Under the condition that the search result is a preset result, determining the media data table and the collection data table as data tables to be operated, wherein the preset result is that the collection data table has the file identification;
And under the condition that the search result is not a preset result, determining the media data table as a data table to be operated.
Optionally, in a case where the collection operation instruction is a collection cancellation instruction, the operation unit 1103 is configured to:
Searching a corresponding collection identifier in the media data table according to the file identifier under the condition that the data table identifier is the identifier of the media data table, and executing deleting operation on the collection identifier;
And searching corresponding collection data in the collection data table according to the file identification under the condition that the data table identification is the identification of the collection data table, and executing deleting operation on the collection data.
Optionally, in a case where the collection operation instruction is a collection adding instruction, the operation unit 1103 is configured to:
under the condition that the data table identifier is the identifier of the media data table, determining a collection identifier adding position corresponding to the file identifier in the media data table according to the file identifier, and adding the collection identifier into the collection identifier adding position;
and under the condition that the data table identifier is the identifier of the collection data table, determining associated data corresponding to the file identifier in the media data table according to the file identifier, determining collection data according to the associated data, and adding the collection data into the collection data table.
Optionally, in a case where the collection operation instruction is a collection query instruction, the operation unit 1103 is configured to:
under the condition that the data table identifier is the identifier of the media data table, inquiring whether a collection identifier corresponding to the file identifier exists in the media data table to obtain an inquiring result;
Under the condition that the data table identifier is the identifier of the collection data table, inquiring whether collection data corresponding to the file identifier exists in the collection data table, and obtaining an inquiring result;
And displaying a corresponding operation interface according to the query result.
Optionally, the collection operation instruction further includes a user ID, and the operation unit 1103 is configured to:
And determining corresponding collection data in the collection data table according to the file identification and the user ID.
Optionally, the operation unit 1103 is configured to:
Determining a sub-data table corresponding to the type in the data table to be operated according to the type of the file identifier;
and executing the operation corresponding to the collection operation instruction in the sub-data table according to the file identification.
As shown in fig. 12, an embodiment of the present application provides a collection operation device including a processor 1201, a communication interface 1202, a memory 1203, and a communication bus 1204, wherein the processor 1201, the communication interface 1202, the memory 1203 complete communication with each other through the communication bus 1204,
A memory 1203 for storing a computer program;
In one embodiment of the present application, the processor 1201 is configured to implement the collection operation method provided in any one of the foregoing method embodiments when executing the program stored in the memory 1203, where the collection operation method includes:
receiving a collection operation instruction of a media database, wherein the collection operation instruction at least comprises a file identifier and a data table identifier;
determining a data table to be operated in a media database according to the data table identifier, wherein the media database comprises a media data table and a collection data table;
and executing the operation corresponding to the collection operation instruction in the data table to be operated according to the file identification.
The present application also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps performed by the collection operation method provided by any one of the method embodiments described above.
The apparatus embodiments described above are merely illustrative, wherein the elements illustrated as separate elements may or may not be physically separate, and the elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
From the above description of embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus a general purpose hardware platform, or may be implemented by hardware. Based on such understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the related art in the form of a software product, which may be stored in a computer readable storage medium, such as ROM/RAM, a magnetic disk, an optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to perform the method described in the respective embodiments or some parts of the embodiments.
It is to be understood that the terminology used herein is for the purpose of describing particular example embodiments only, and is not intended to be limiting. As used herein, the singular forms "a", "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. The terms "comprises," "comprising," "includes," "including," and "having" are inclusive and therefore specify the presence of stated features, steps, operations, elements, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, elements, components, and/or groups thereof. The method steps, processes, and operations described herein are not to be construed as necessarily requiring their performance in the particular order described or illustrated, unless an order of performance is explicitly stated. It should also be appreciated that additional or alternative steps may be used.
The foregoing is only a specific embodiment of the invention to enable those skilled in the art to understand or practice the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202510155813.6A CN120179620A (en) | 2025-02-12 | 2025-02-12 | Collection operation method, device, equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202510155813.6A CN120179620A (en) | 2025-02-12 | 2025-02-12 | Collection operation method, device, equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN120179620A true CN120179620A (en) | 2025-06-20 |
Family
ID=96031839
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202510155813.6A Pending CN120179620A (en) | 2025-02-12 | 2025-02-12 | Collection operation method, device, equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN120179620A (en) |
-
2025
- 2025-02-12 CN CN202510155813.6A patent/CN120179620A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6587856B1 (en) | Method and system for representing and accessing object-oriented data in a relational database system | |
CA2619230C (en) | Annotating documents in a collaborative application with data in disparate information systems | |
US7716171B2 (en) | Snapshot indexing | |
US8595259B2 (en) | Web data usage platform | |
US7873625B2 (en) | File indexing framework and symbolic name maintenance framework | |
JP5023715B2 (en) | Information processing system, information processing apparatus, and program | |
KR101682738B1 (en) | Managed system extensibility | |
US7966603B2 (en) | Systems and methods for context-based content management | |
EP1480132B1 (en) | System and method for identifying and storing changes made to a table | |
US20060112067A1 (en) | Interactive system for collecting metadata | |
US7376658B1 (en) | Managing cross-store relationships to data objects | |
US7197491B1 (en) | Architecture and implementation of a dynamic RMI server configuration hierarchy to support federated search and update across heterogeneous datastores | |
CN111274263A (en) | Visual database change statement generation method and device and storage medium | |
CN112559913B (en) | Data processing method, device, computing equipment and readable storage medium | |
US20060117049A1 (en) | Processing path-based database operations | |
CN104834661B (en) | Management method, management equipment and management system | |
JP4048006B2 (en) | Database search system and method | |
CN120179620A (en) | Collection operation method, device, equipment and storage medium | |
US9361359B1 (en) | Accessing schema-free databases | |
CN108322380B (en) | Method and device for calling data and method and device for pushing information | |
CN108694219B (en) | Data processing method and device | |
US7856455B2 (en) | System, method and program product for generating triggers for a relational database | |
JPH11120054A (en) | Device and method for managing electronic document, and recording medium recorded with electronic document managing program | |
CN107729013B (en) | Method and computer-readable storage medium for managing operation buttons on web pages | |
JP2023176448A (en) | Information processing device, information processing system, information processing method, and program |
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 |