I have an SQLite table and I want to run a query at the end of each month to delete a row from the table, is there a way to do so?
Asked
Active
Viewed 37 times
0
-
1use workmanger and schedule a task every 30 days. https://stackoverflow.com/questions/53901179/android-work-manager-how-to-enqueue-jobs-once-a-month – akshay_shahane Feb 02 '21 at 07:05
1 Answers
0
To delete a row just use:
db.delete(String table,
String whereClause,
String[] whereArgs)
ex.
db.delete("yourTable", "yourRow", null);
Now to recognize the day of the month use Calendar class:
Calendar calendar = Calendar.getInstance();
int dayOfTheMonth = calendar.get(Calendar.DAY_OF_MONTH);
https://developer.android.com/reference/java/util/Calendar#DAY_OF_MONTH

Peppinhood
- 39
- 9