Android Open Source - text-snippets Text Snippets Backup Agent






From Project

Back to project page text-snippets.

License

The source code is released under:

GNU General Public License

If you think the Android project text-snippets 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 org.sirimangalo.textsnippets;
/*from ww  w.j  a  v a 2s.c  o  m*/
import java.io.IOException;

import android.app.backup.BackupAgentHelper;
import android.app.backup.BackupDataInput;
import android.app.backup.BackupDataOutput;
import android.app.backup.FileBackupHelper;
import android.os.ParcelFileDescriptor;
import android.util.Log;

public class TextSnippetsBackupAgent extends BackupAgentHelper {

    private static final String DB_NAME = "snippets.db";

    @Override
    public void onCreate(){

        FileBackupHelper dbs = new FileBackupHelper(this,
            "../databases/" + DB_NAME);
        
        addHelper("adbs", dbs);
      
    }

    @Override
    public void onBackup(ParcelFileDescriptor oldState, BackupDataOutput data,
         ParcelFileDescriptor newState) throws IOException {
            synchronized (MySQLiteHelper.dbLock) {
                    super.onBackup(oldState, data, newState);
            }
    }

    @Override
    public void onRestore(BackupDataInput data, int appVersionCode,
                    ParcelFileDescriptor newState) throws IOException {
            Log.d("TextSnippetsBackupAgent", "onRestore called");

            synchronized (MySQLiteHelper.dbLock) {
                    Log.d("TextSnippetsBackupAgent", "onRestore in-lock");

                    super.onRestore(data, appVersionCode, newState);
            }
    }
    
}




Java Source Code List

org.sirimangalo.textsnippets.MySQLiteHelper.java
org.sirimangalo.textsnippets.SnippetAdapter.java
org.sirimangalo.textsnippets.SnippetWidgetProvider.java
org.sirimangalo.textsnippets.SnippetWidgetService.java
org.sirimangalo.textsnippets.Snippet.java
org.sirimangalo.textsnippets.SnippetsActivity.java
org.sirimangalo.textsnippets.SnippetsDataSource.java
org.sirimangalo.textsnippets.TextSnippetsBackupAgent.java