How to update document in sqlite database & phone storage in Android? -
i building app in android using web services. trying synchronization function. getting properties web server , have 1 boolean value it, if boolean true update downloaded document.
but stuck on here either need first delete document , replace or can directly replace document. code this:
soapobject docresponse = (soapobject)envelope.getresponse(); log.i("uspdated documentss", docresponse.tostring()); for(int i=0; < docresponse.getpropertycount(); i++) { soapobject singlesubfolder = (soapobject)docresponse.getproperty(i); id = singlesubfolder.getproperty(0).tostring(); filelongname = singlesubfolder.getproperty(1).tostring(); userfilename = singlesubfolder.getproperty(2).tostring(); url = singlesubfolder.getproperty(3).tostring(); fileextension = singlesubfolder.getproperty(4).tostring(); lastmodifieddate = singlesubfolder.getproperty(5).tostring(); subjecttype = singlesubfolder.getproperty(6).tostring(); isupdated = singlesubfolder.hasproperty("isupdated"); db = new dms_database(context); if(isupdated==true) { // how perform replace function database here??? // there need of download manager again download new folder phone storage or database??? downloadmanager.request request = new downloadmanager.request(uri.parse(url)); request.settitle(userfilename); // in order if run, must use android 3.2 compile app if (build.version.sdk_int >= build.version_codes.honeycomb) { request.allowscanningbymediascanner(); request.setnotificationvisibility(downloadmanager.request.visibility_visible_notify_completed); } request.setdestinationinexternalpublicdir(environment.directory_downloads + "/downloads", userfilename); downloadmanager manager = (downloadmanager)activtyclass.mact.getsystemservice(context.download_service); manager.enqueue(request); } db.close(); } } catch(exception e) { e.printstacktrace(); toast.maketext(context, " network exception : " + e + "please check network connectivity.", toast.length_long).show(); }
database:this database method...is right???
public void update_doc(string id, string name, string url) { sqlitedatabase db = this.getwritabledatabase(); contentvalues updatenote = new contentvalues(); updatenote.put(document_id, id); updatenote.put(document_name, name); updatenote.put(document_url, url); db.update(document_table, updatenote, document_id + "=?" , new string[] {string.valueof(id)}); }
public void update_doc(string id, string name, string url) { sqlitedatabase db = this.getwritabledatabase(); contentvalues updatenote = new contentvalues(); updatenote.put(document_id, id); updatenote.put(document_name, name); updatenote.put(document_url, url); long id = db.insertwithonconflict(document_table, null, updatenote, sqlitedatabase.conflict_ignore); if (id == -1) { db.update(document_table, updatenote, document_id + "=?" , new string[] {string.valueof(id)}); } }
Comments
Post a Comment