Android Open Source - Android-Backup Backup Store






From Project

Back to project page Android-Backup.

License

The source code is released under:

GNU General Public License

If you think the Android project Android-Backup 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

package com.Akkad.AndroidBackup;
/*  w ww  .j  av a  2 s.  com*/
import java.io.File;
import java.io.FilenameFilter;

import android.os.Environment;

public class BackupStore {
  private static String backupFolderLocation = Environment.getExternalStorageDirectory().getPath() + "/AndroidBackup/"; // TODO implement a setting to change this folder
  private static File mfile = new File(backupFolderLocation);

  public static int getBackupCount(String packageName) {
    File[] backups = getBackups();
    int backupCount = 0;
    for (int i = 0; i < backups.length; i++) {
      if (backups[i].getName().toLowerCase().contains(packageName.toLowerCase())) {
        backupCount++;
      }
    }
    return backupCount;
  }

  public static File[] getBackupFolderFiles() {
    return mfile.listFiles();
  }

  public static String getBackupFolderLocation() {
    return backupFolderLocation;
  }

  public static Backup[] getBackupInformation() {
    File loadBackupInformation[] = getBackups();
    Backup backups[] = new Backup[loadBackupInformation.length];
    for (int i = 0; i < backups.length; i++) {
      backups[i] = new Backup(loadBackupInformation[i].getPath());
    }
    return backups;
  }

  public static File[] getBackups() {
    return mfile.listFiles(new FilenameFilter() {
      public boolean accept(File dir, String filename) {
        return filename.endsWith(".information");
      }
    });
  }

  public static Backup[] getPackageBackupInformation(String packageName) {
    Backup[] backupList = getBackupInformation();
    Backup[] filteredList = new Backup[getBackupCount(packageName)];
    int filteredCounter = 0;
    for (int i = 0; i < backupList.length; i++) {
      if (backupList[i].getApp_package_name().equals(packageName)) {
        filteredList[filteredCounter++] = backupList[i];
      }
    }
    return filteredList;
  }

  public static void setBackupFolderLocation(String backupFolderLocation) {
    BackupStore.backupFolderLocation = backupFolderLocation;
  }
}




Java Source Code List

com.Akkad.AndroidBackup.AndroidBackupActivity.java
com.Akkad.AndroidBackup.AppInfoAdapter.java
com.Akkad.AndroidBackup.ApplicationsFragment.java
com.Akkad.AndroidBackup.BackupListAdapter.java
com.Akkad.AndroidBackup.BackupStore.java
com.Akkad.AndroidBackup.Backup.java
com.Akkad.AndroidBackup.Core.java
com.Akkad.AndroidBackup.InformationFragment.java
com.Akkad.AndroidBackup.ScheduleFragment.java
com.Akkad.AndroidBackup.TabsPagerAdapter.java
com.Akkad.AndroidBackup.TasksFragment.java