Android : Compate two variable at differente time : I'm a new Android developer, and for my app, i would like to compare different variables over time.
My Service counts the number of SMS inside the smartphone. 

    private static final Uri SMS_URI_ALL = Uri.parse("content://sms/");
    final List<String> messages = new ArrayList<>();
        String id;

        final Cursor cursor = getContentResolver().query(SmsReader.SMS_URI_ALL,null, null,null, null);
        assert cursor != null;
        if (cursor.moveToFirst()){
            do {
                id = cursor.getString(cursor.getColumnIndexOrThrow("_id"));
                messages.add(id);
                currentMessage = messages.size();
            } while (cursor.moveToNext());

        }
        if (! cursor.isClosed()){
            cursor.close();
    }

Every 15 min this service starts, and i would like to compare the value of "currentMessage" and calculate the difference between the old value of "currentMessage" and the new value of "currentMessage" for know how many message I have sent, recevied during this period of 15min 
I dont know how to implemante it, can you help me please :D

Thanks you  