Back to project page openhds-tablet.
The source code is released under:
OPENHDS PLATFORM OPENSOURCE LICENSE AGREEMENT Copyright (c) 2013 University of Southern Maine. All rights reserved. Redistribution and use in source and binary forms, with or without mo...
If you think the Android project openhds-tablet listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package org.openhds.mobile.database; /*w w w . ja v a 2 s . c o m*/ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import org.openhds.mobile.OpenHDS; import org.openhds.mobile.model.FormXmlReader; import org.openhds.mobile.model.Location; import android.content.ContentResolver; import android.content.ContentValues; import android.util.Log; public class LocationUpdate implements Updatable { public void updateDatabase(ContentResolver resolver, String filepath,String jrFormId) { Location location = readLocationFromXml(filepath,jrFormId); if (location == null) { Log.e(LocationUpdate.class.getName(), "Was not able to read location from XML file"); return; } writeLocationToDatabase(resolver, location); } private void writeLocationToDatabase(ContentResolver resolver, Location location) { ContentValues cv = new ContentValues(); cv.put(OpenHDS.Locations.COLUMN_LOCATION_EXTID, location.getExtId()); cv.put(OpenHDS.Locations.COLUMN_LOCATION_HIERARCHY, location.getHierarchy()); cv.put(OpenHDS.Locations.COLUMN_LOCATION_NAME, location.getName()); cv.put(OpenHDS.Locations.COLUMN_LOCATION_LATITUDE, ""); cv.put(OpenHDS.Locations.COLUMN_LOCATION_LONGITUDE, ""); resolver.insert(OpenHDS.Locations.CONTENT_ID_URI_BASE, cv); } private Location readLocationFromXml(String filepath,String jrFormId ) { File file = new File(filepath); FormXmlReader reader = new FormXmlReader(); try { return reader.readLocation(new FileInputStream(file), jrFormId); } catch (FileNotFoundException e) { return null; } } }