android - Only three records in SQLite database at a time -
I am developing an Android application in which I need to keep a record of the three most recent actions the user made on the screen I have these records stored in the SQLite database.
I want to implement a specific feature, such as whenever a fourth action is taken, the least recent record automatically changes with the new one.
I discovered some ways to limit the number of rows, one of them was to use the trigger in the database and I am not very familiar with the use of the trigger.
Please help me implement the functionality.
according to your post, I think that 3 is the only arbitrary number that you said. You have a large database and you want to restrict numbers or rows with a specific limit.
Use the trigger below
Trigger trg 1 when the table 1 Press INSERT (Select number (*) from Table 1, delete from BEGIN Table 1; WHERE _id = (SELECT min (_id) from Table 1); Even
Assuming that _id is the identity column, it should work.
If you do not want to use _ID, then the oldest log identification Use a datetime field to which 1 log is entered within the same millisecond fraction (better use min (_id) because it is the primary primary primary key)
Comments
Post a Comment