Is there a way to export a .geodatabase dataset to Excel or CSV file by android mobile application?
For example, I want to have a button in my app that exports a .geodatabase dataset stored locally on my device to Excel or CSV file and save it on the device.
If this possible, how can I do this?
Any help is appreciated!
Hani
Very interesting.
So there is no API in the product that does this, at least not at this time.
However, there are APIs to access the necessary geodatabase fields and values that you can take advantage of to accomplish something like this.
For example, this is what I did. It worked for me:
Something like that. May sound like a hack, and I would share my exact code, but it is embarrassingly hackish-looking. But it worked....
Care to share more details about the need to do such a thing? Thanks!
Thank you very much Eric for showing interest, and for your prompt input!
Actually, I am not a developer, and I think it will take me a lot of time to complete all the steps you outlined in your post. It will be highly appreciated if you share your code, so I can use it and I am sure that it will be a helpful resource for me.
Once again, thank you!
I will share it as soon as I can clean things up....stay tuned!
Hi Eric-
Still staying tuned... did you get the code written for this? I'm about to write the same code, myself. Would be great to not have to reinvent the wheel...
-Melo
Ah! Caught me. I will try to do this asap. I'm sorry for letting this get away!
Thanks! Code was perfect. I adapted it slightly to add Latitude and Longitude fields. I also adapt the date field from epoch to a readable format. So I thought I'd share that code here in case it is useful to anyone.
PrintWriter writer = new PrintWriter(file.getAbsolutePath(), "WINDOWS-1252"); writer.write("Longitude" + ","); writer.write("Latitude" + ","); for(com.esri.core.map.Field field: obsTable.getFields()){ writer.write(field.getName() + ","); } Iterator<Object> it = objs.iterator(); while(it.hasNext()){ GeodatabaseFeature feature = (GeodatabaseFeature)it.next(); Point point = (Point) GeometryEngine.project(feature.getGeometry(), SpatialReference.create(102113), SpatialReference.create(4326)); StringBuffer values = new StringBuffer(); values.append(point.getX() + ","); values.append(point.getY() + ","); for(com.esri.core.map.Field f : objs.getFields()){ if(f.getName().equals("Date")){ values.append(epochTimeConvert(Long.parseLong(feature.getAttributeValue(f).toString()), "EEE MMM dd, yyyy hh:mm a") + ","); } else{ values.append(feature.getAttributeValue(f) + ","); } } writer.println(values); } writer.close();