java - How to save sqlite db file of another android application.? -


i developed application sales force in our company.most of them sales in rural areas , more times no signal areas.then tell synch sales server.but more sales details lost. try develop tool third party tool app save local db file phone internal memory.then can via email.here code

    try {         file sd = environment.getexternalstoragedirectory();         file data = environment.getdatadirectory();         toast.maketext(getapplicationcontext(), "sd card detecting ", toast.length_short).show();         if (sd.canwrite()) {             toast.maketext(getapplicationcontext(), "backup writing sd card", toast.length_short).show();             string currentdbpath = "//data//com.lk.lankabell.android.activity//databases//tsrdbnew";             string backupdbpath = "tsrdbnew-backup";             file currentdb = new file(data, currentdbpath);             file backupdb = new file(sd, backupdbpath);              if (currentdb.exists()) {                 filechannel src = new fileinputstream(currentdb).getchannel();                 filechannel dst = new fileoutputstream(backupdb).getchannel();                 dst.transferfrom(src, 0, src.size());                 src.close();                 dst.close();                 toast.maketext(getapplicationcontext(), "backup successful sd card", toast.length_short).show();             }         }     } catch (exception e) {         toast.maketext(getapplicationcontext(), "backup un-success sd card", toast.length_short).show();     } 

i used main app [android+ksoap+axis2] technologies.

please advice me implement this.i tried above code.but doesn't work.its need sd card too.any issue db url.?

enter image description here

you cannot "get" file data "private" folder of app easily. best way is, creating/updateing/deleting classes db, create new query gets information want, save string, , save in sdcard in txt file, or json file, or format want. possible solution (without db model can't more) using csv format:

public void generatetxtonsd(string[] lines_txt)  {     // lines_txt contains array of each register in csv format.     try     {         file root = new file(environment.getexternalstoragedirectory(),"nameofdirectoryyouwanttosave");         if (!root.exists())          {             root.mkdirs();         }         calendar cal = calendar.getinstance();         // made no override versions of data have stored.         string hour= string.valueof(cal.get(cal.hour_of_day))+"_"+string.valueof(cal.get(cal.minute))+"_"+string.valueof(cal.get(cal.second));         file txtfile = new file(root, name_txt+hour+".txt");         filewriter writer = new filewriter(txtfile);         //every line contain info want save         (string line_txt : lines_txt) {             writer.append(line_txt);             writer.append('\r');             writer.append('\n');          }         writer.flush();         writer.close();       }     catch(ioexception e)     {         // error      } }  

hope helps.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -