sqlite - Android - Create Multiple Exported Databases And Allow User To Select Which One To Import -


i have following code used create backup of sqlite database;

    file sd = environment.getexternalstoragedirectory();     file data = environment.getdatadirectory();     filechannel source = null;     filechannel destination = null;     string currentdbpath = "/data/com.sjhdevelopment.shaunharrison.myejuiceapp/databases/ejuicedata.db";     string backupdbpath = "ejuicedata.db";       file currentdb = new file(data,currentdbpath);     file backupdb = new file(sd,backupdbpath);      try     {         source = new fileinputstream(currentdb).getchannel();         destination = new fileoutputstream(backupdb).getchannel();         destination.transferfrom(source,0,source.size());         source.close();         destination.close();         toast.maketext(this, "db exported", toast.length_long).show();     }     catch(exception e)     {         showerror("error", e.getmessage());     } 

and have following code import sqlite database

 file sd = environment.getexternalstoragedirectory();  file data = environment.getdatadirectory();   if(sd.canwrite())  {    string currentdbpath="/data/com.sjhdevelopment.shaunharrison.myejuiceapp/databases/ejuicedata.db";    string backupdbpath = "ejuicedata.db";    file backupdb = new file (data,currentdbpath);    file currentdb = new file(sd, backupdbpath);     try {          filechannel src =new fileinputstream(currentdb).getchannel();          filechannel dst = new fileoutputstream(backupdb).getchannel();          dst.transferfrom(src, 0, src.size());          src.close();          dst.close();          toast.maketext(getbasecontext(), "db imported", toast.length_long).show();        }    catch(exception e)    {          showerror("error", e.getmessage());    } 

my problem want user able make multiple backups instead of one, know how can todays date via following;

    calendar calendar = calendar.getinstance();     date today = calendar.gettime();     dateformat dateformat = new simpledateformat("dd/mmm/yyyy");     string todayasstring = dateformat.format(today); 

but in code export code todayasstring go?

also when comes importing how allow user browse files select backup import?

thanks

you can use dialogs. single choice looking for.


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -