Create Feature for offline Runtime Geodatabase

3338
2
06-03-2014 03:09 PM
ForrestKaye
New Contributor III
I am trying to create a point feature and add it to an offline runtime Geodatabase.  I have followed the "Offline editor" sample to the best of my ability but am still having trouble figuring it out.  The offline editor sample seemed pretty complex and does not seem to work all that well itself.

My approach was to use the "Create Runtime Geodatabase" sample and add in a map touch listener that added a point on each tap to the wildfire.geodatabase. 

I've worked through what seems like should work but when I try to verify that I've added a feature by using the queries "gdbFeatureTable.getNumberOfFeatures()" and "gdbFeatureTable.getAddedFeaturesCount()" they never change.


Do I need to do something else to do the GeodatabaseFeatureTable besides "addFeature(feature)" like .Save() or something?

Will the feature be added if it is blank? Since I'm only using gdbFeatureTable.createNewFeature() instead of gdbFeatureTable.createFeatureWithTemplate().  Are there possibly requirements not being met by my blank feature that is then being tossed out on add?

My goal is to just get something rolling and build up in complexity.

Here is my code:


private void handleTap(final MotionEvent e) {

    TextView pTextView1 = (TextView) findViewById(R.id.editText1);
    
    localGdbFilePath = createGeodatabaseFilePath();
    
 Geodatabase localGdb = null;
    try {
      localGdb = new Geodatabase(localGdbFilePath);
    } catch (FileNotFoundException a) {
      a.printStackTrace();
    }
    
    for (GeodatabaseFeatureTable gdbFeatureTable : localGdb.getGeodatabaseTables()) {
        if (gdbFeatureTable.hasGeometry())
         
         if (gdbFeatureTable.getGeometryType() == Geometry.Type.POINT ){ 
          //Checking on status of table...
          pTextView1.setText(gdbFeatureTable.getGeometryType() + " " + gdbFeatureTable.isEditable() + " " + gdbFeatureTable.getTableName() + " " + gdbFeatureTable.getEditableAttributeFields());

          //Point point = map.toMapPoint(new Point(e.getX(), e.getY()));
          Double X = mMapView.getCenter().getX();
          Double Y = mMapView.getCenter().getY();
          
          Point point = new Point(X,Y);
                        //not using the geometry at this point...

          
          
          Feature pFeature2 = null;
    try {
     pFeature2 = gdbFeatureTable.createNewFeature();
    } catch (TableException e1) {

     e1.printStackTrace();
    }
          

           try {
            gdbFeatureTable.addFeature(pFeature2);
     } catch (TableException e1) {

      e1.printStackTrace();
     }
          }
      }
     }


Any insight is much appreciated, Thanks!
0 Kudos
2 Replies
teamIgal
New Contributor III
Hi,

In version 10.2.2 and 10.2.3 ESRI removed the ability to add, update or delete features from a geodatabase that was created in the ArcMap.
0 Kudos
ForrestKaye
New Contributor III
The geodatabase was not created from ArcMap.  It was created from an online resource (Create Runtime Geodatabase sample) and downloaded as an editable runtime Geodatabase, so that is not the issue. 

I am trying to use the 10.2.3 offline capabilities. 


I did notice as I've been working through this that I was using Feature instead of GeodatabaseFeature.  Could this be where some of the issue stems from? Is my understanding correct in that a map.Feature is a graphic?  But can also have geometry and attributes??

com.esri.core.map.Feature

vs

com.esri.core.Geodatabase.GeodatabaseFeature
0 Kudos