Android Open Source - Aegis Backup Utils






From Project

Back to project page Aegis.

License

The source code is released under:

GNU General Public License

If you think the Android project Aegis 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.decad3nce.aegis;
//from  w w  w .  j  a  v a  2 s  .c o  m
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class BackupUtils extends Utils {

    public static Uri getAllCallLogs(ContentResolver cr, Uri internal, Context context, String timeStamp) {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yy HH:mm");
        String[] callLogArray = new String[3];
        String strOrder = android.provider.CallLog.Calls.DATE + " DESC";
        Uri callUri = Uri.parse("content://call_log/calls");
        Cursor cur = cr.query(callUri, null, null, null, strOrder);
        
        FileOutputStream fOut = null;
        try {
            fOut = context.openFileOutput("call_logs_" + timeStamp + ".txt",
                    Context.MODE_PRIVATE);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        
        OutputStreamWriter osw = new OutputStreamWriter(fOut);
        
        while (cur.moveToNext()) {
            callLogArray[0] = cur.getString(cur
                    .getColumnIndex(android.provider.CallLog.Calls.NUMBER));
            callLogArray[1] = cur.getString(cur
                    .getColumnIndex(android.provider.CallLog.Calls.CACHED_NAME));
            
            int thirdIndex = cur.getColumnIndex(android.provider.CallLog.Calls.DATE);
            long seconds = cur.getLong(thirdIndex);
            String dateString = formatter.format(new Date(seconds));
            callLogArray[2] = dateString;
        
            writeToOutputStreamArray(callLogArray, osw);
        }
        
        try {
            osw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        return internal;
    }
    
    public static Uri getSMSLogs(ContentResolver cr, Uri internal, Context context, String timeStamp) {
        String[] smsLogArray = new String[2];
        Uri uri = Uri.parse("content://sms/inbox");
        Cursor cur= cr.query(uri, null, null ,null,null);
        FileOutputStream fOut = null;
        
        try {
            fOut = context.openFileOutput("sms_logs_" + timeStamp + ".txt",
                    Context.MODE_PRIVATE);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        
        OutputStreamWriter osw = new OutputStreamWriter(fOut);
        
        while (cur.moveToNext()) {
            smsLogArray[0] = cur.getString(cur.getColumnIndexOrThrow("address")).toString();
            smsLogArray[1] = cur.getString(cur.getColumnIndexOrThrow("body")).toString();
            
            writeToOutputStreamArray(smsLogArray, osw);
        }
        
        try {
            osw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        return internal;
    }
    
    private static void writeToOutputStreamArray(String[] array, OutputStreamWriter oswriter) {
        for (int i = 0; i < array.length; i++) {
            try {
                oswriter.append(array[i] + "  ");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        try {
            oswriter.append("\n");
            oswriter.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}




Java Source Code List

com.decad3nce.aegis.AegisActivity.java
com.decad3nce.aegis.AlarmService.java
com.decad3nce.aegis.BackupDropboxAccountsActivity.java
com.decad3nce.aegis.BackupGoogleAccountsActivity.java
com.decad3nce.aegis.BackupUtils.java
com.decad3nce.aegis.DeviceAdmin.java
com.decad3nce.aegis.DialerCodeReceiver.java
com.decad3nce.aegis.DrawerLayoutAdapter.java
com.decad3nce.aegis.FontAdapter.java
com.decad3nce.aegis.LoginActivity.java
com.decad3nce.aegis.PhoneTrackerActivity.java
com.decad3nce.aegis.RegisterActivity.java
com.decad3nce.aegis.RootTask.java
com.decad3nce.aegis.SIMStateReceiver.java
com.decad3nce.aegis.SMSReceiver.java
com.decad3nce.aegis.Utils.java
com.decad3nce.aegis.WipeBaseActivity.java
com.decad3nce.aegis.WipeTask.java
com.decad3nce.aegis.Fragments.AboutFragment.java
com.decad3nce.aegis.Fragments.AdvancedSettingsFragment.java
com.decad3nce.aegis.Fragments.BackupAccountsDialogFragment.java
com.decad3nce.aegis.Fragments.ChooseBackupProgramDialogFragment.java
com.decad3nce.aegis.Fragments.InstallToSystemDialogFragment.java
com.decad3nce.aegis.Fragments.SIMListFragment.java
com.decad3nce.aegis.Fragments.SMSAlarmFragment.java
com.decad3nce.aegis.Fragments.SMSDataFragment.java
com.decad3nce.aegis.Fragments.SMSLocateFragment.java
com.decad3nce.aegis.Fragments.SMSLockFragment.java
com.decad3nce.aegis.Fragments.SMSWipeFragment.java