Android:How to Update a local XML file when device finds internet connectivity -


i developing android application. application has xml file locally stored within application apk file. file contains data displayed in application. have latest updated xml file on server. want update file on device either in background or notifying user. whenever device finds internet connectivity,it should check file modification date , should update/replace old file new file server.

you can check internet availability code:

public boolean isconnectivityon(context ctx) {     boolean rescode = false;      try {         connectivitymanager cm =                 (connectivitymanager) ctx.getsystemservice(context.connectivity_service);          rescode = cm.getactivenetworkinfo().isconnectedorconnecting();      } catch (exception e) {         // todo: handle exception         e.printstacktrace();             }      return rescode; } 

having in manifest following permissions:

<uses-permission android:name="android.permission.internet" /> <uses-permission android:name="android.permission.access_network_state" /> 

and calling above method:

if (isconnectivityon()) {     //update xml } else {      //don't update xml } 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -