Hi,
I want to be able to add features to a runtime content dataset (.geodatabase) with the following scenario: I have a points-dataset (points.geodatabase) stored on my android device, I built an app that views these points, and I want to edit this dataset from my android device by adding a new point feature (with 150,000 x-coordinate and 160000 y-coordinate) to it. I tried the standard guide in this link and wrote the code below but still, the dataset is not edited and the new point is not added.
My question is: How can I add features to a .geodatabase dataset from my android device?
Any help is highly appreciated
Hani
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//make a map of attributes
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("Name_English", "PointA");
/*point=(Point) locgraphic.getGeometry();*/
point=new Point(150000, 160000);
try {
//Create a feature with these attributes at the given point
GeodatabaseFeature gdbFeature = new GeodatabaseFeature(attributes, point, gft);
//Add the feature into the geodatabase table (gft) gft.addFeature(gdbFeature);
s.addGraphic(new Graphic(point, new SimpleMarkerSymbol(Color.RED,15,SimpleMarkerSymbol.STYLE.CIRCLE)));
} catch (TableException e) {
// report errors, e.g. to console
}
Toast.makeText(getApplicationContext(), "Saved!", 3000).show();
}
});
Button btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
//make a map of attributes
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put("Name_English", "PointA");
/*point=(Point) locgraphic.getGeometry();*/
point=new Point(150000, 160000);
try {
//Create a feature with these attributes at the given point
GeodatabaseFeature gdbFeature = new GeodatabaseFeature(attributes, point, gft);
//Add the feature into the geodatabase table (gft) gft.addFeature(gdbFeature);
s.addGraphic(new Graphic(point, new SimpleMarkerSymbol(Color.RED,15,SimpleMarkerSymbol.STYLE.CIRCLE)));
} catch (TableException e) {
// report errors, e.g. to console
}
Toast.makeText(getApplicationContext(), "Saved!", 3000).show();
}
});
Solved! Go to Solution.
[Unfortunately] I don't think there is any feasible way to make ArcMap created databases and content editable. For me services pattern was too annoying and I went on with adding Spatialite database to my project - They are editable but of course you have to write your own handlers for editing and showing your data on the map.
(Reasons: Services way doesn't support complex enough relationships for our organizations needs and you must use new ArcGis server or ArcGis online for serving that data. We want this app to be desktop-pda-desktop, not Desktop-[adminperson]-Server-[gisexpert]-Pda-Server-[adminperson]-Desktop. And we also wanted it to be fully offline-able.
Many thanks Tero for the valuable input, and for sharing your experience!