app/src/main/java/fr/neamar/kiss/db/DBHelper.java
/**
     * Insert new item into history
     *
     * @param context android context
     * @param query   query to insert
     * @param record  record to insert
     */
Insert new item into history
@param context android context
@param query   query to insert
@param record  record to insert
Insert new item into history @param context android context @param query query to insert @param record record to insert
public static void insertHistory(Context context, String query, String record) {
        SQLiteDatabase db = getDatabase(context);
        ContentValues values = new ContentValues();
        values.put("query", query);
        values.put("record", record);
        values.put("timeStamp", System.currentTimeMillis());
        db.insert("history", null, values);
        if (Math.random() <= 0.005) {
            long twoMonthsAgo = 7776000000L; 
            db.delete("history", "timeStamp < ?", new String[]{Long.toString(System.currentTimeMillis() - twoMonthsAgo)});
            db.execSQL("VACUUM");
        }
    }
public static void insertHistory ( Context context , String query , String record ) { SQLiteDatabase db = getDatabase ( context ) ; ContentValues values = new ContentValues ( ) ; values . put ( "query" , query ) ; values . put ( "record" , record ) ; values . put ( "timeStamp" , System . currentTimeMillis ( ) ) ; db . insert ( "history" , null , values ) ; if ( Math . random ( ) <= 0.005 ) { long twoMonthsAgo = 7776000000L ; db . delete ( "history" , "timeStamp < ?" , new String [ ] { Long . toString ( System . currentTimeMillis ( ) - twoMonthsAgo ) } ) ; db . execSQL ( "VACUUM" ) ; } }
Insert new item into history
 @param context android context
 @param query   query to insert
 @param record  record to insert
Insert new item into history @param context android context @param query query to insert @param record record to insert
// Roughly every 200 inserts, clean up the history of items older than 3 months // 1000 * 60 * 60 * 24 * 30 * 3; // And vacuum the DB for speed