java - How I can create backups for my notes in Android app by using Gmail account or a server or by extract a file? -


i have android app, , it's writing , saves notes in sqlite database. need make backups notes using gmail account (if user sign in email in app, app automatically syncs , gets notes). or saving notes on server (if user press sync button, app automatically gets notes (but here, how app or server knows if user correct user, , gets correct notes?!)). or extract file directory, , file contains notes, if user press restore button in app, app start looking file in directories , gets notes.

i searched that, have no idea how can start!

can explain whole idea that?! (if can bring source codes or tutorials that, explanation! :d).

  • note: beginner, please try make answers more simple. lot!

  • here app on google play store: my notes app

you can use android's backupagenthelper.

here sample: add in manifest:

    <application             android:allowbackup="true"...> <meta-data android:name="com.google.android.backup.api_key" android:value="key_from_google_api" /> .... </application> 

create 1 class as:

public class mybackupagent extends backupagenthelper {      private string key = "key";      @override     public void oncreate() {         addhelper(key, new filebackuphelper(this, database_name));     }      @override     public file getfilesdir(){         file path = getdatabasepath(database_name);         return path.getparentfile();     }      @override     public void onbackup(parcelfiledescriptor oldstate, backupdataoutput data, parcelfiledescriptor newstate) throws ioexception {         super.onbackup(oldstate, data, newstate);     }      @override     public void onrestore(backupdatainput data, int appversioncode, parcelfiledescriptor newstate) throws ioexception {         super.onrestore(data, appversioncode, newstate);     } } 

you ready go!!!


Comments