/* 
 * Copyright 2015 by AVM GmbH <info@avm.de>
 *
 * This software contains free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License ("License") as 
 * published by the Free Software Foundation  (version 3 of the License). 
 * This software is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the copy of the 
 * License you received along with this software for more details.
 */

package de.avm.fundamentals.logger;

import android.os.AsyncTask;

import java.io.File;

public class LogRemoverTask extends AsyncTask<Void, Void, Void> {

    public static final int MAX_LOG_FILES_COUNT = 2;

    @Override
    protected Void doInBackground(Void... params) {
        File[] files = FileLog.getSortedFiles();
        for(int i = 0; i < files.length - 1; i++){
            if(i < (files.length - MAX_LOG_FILES_COUNT)){
                boolean delete = files[i].delete();
            }
        }
        return null;
    }
}
