Android Open Source - tazDownloader Cleanup Service






From Project

Back to project page tazDownloader.

License

The source code is released under:

GNU General Public License

If you think the Android project tazDownloader listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright (c) 2012 Olaf Sebelin.//w  w  w . j a  v a2 s  . com
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program 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
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ******************************************************************************/
package read.taz;

import java.util.Calendar;

import android.app.IntentService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Log;

public class CleanupService extends IntentService {

  public CleanupService() {
    super("taz cleanup service");
  }

  @Override
  protected void onHandleIntent(Intent intent) {

    SharedPreferences preferences = PreferenceManager
        .getDefaultSharedPreferences(this);

    int offset = Integer.parseInt(preferences.getString(
        getString(R.string.deleteThresholdKey), "365"));
    if (offset <= 0) {
      Log.i(getClass().getSimpleName(),
          "User requested to NOT cleanup old files");
      return;
    }

    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.DAY_OF_YEAR, -offset);
    Log.d(getClass().getSimpleName(),
        "Deleting files older than " + cal.getTime());
    new TazFileFactory(this).cleanupFilesOlderThan(cal.getTime());
  }

}




Java Source Code List

read.taz.AbstractTazReaderMainActivity.java
read.taz.CleanupService.java
read.taz.DownloadActivity.java
read.taz.SettingsActivity.java
read.taz.ShowOnStartup.java
read.taz.TazDownloadListener.java
read.taz.TazDownloadService.java
read.taz.TazDownloader.java
read.taz.TazFileFactory.java
read.taz.TazFile.java
read.taz.TazReaderActivity.java