private static int doInBackground(final Uri uri) {
        BufferedInputStream stream = null;
        try {
            final InputStream is = ContentStorage.get().openForRead(uri);
            if (is == null) {
                return 0;
            }
            stream = new BufferedInputStream(is);

            GPXIndividualRouteParser parser = new GPXIndividualRouteParser("http://www.topografix.com/GPX/1/1", "1.1");
            Route route = null;
            try {
                try {
                    route = parser.parse(stream);
                } catch (ParserException e) {
                    // retry with v1.0 format
                    parser = new GPXIndividualRouteParser("http://www.topografix.com/GPX/1/0", "1.0");
                    route = parser.parse(stream);
                }
            } catch (IOException | ParserException e) {
                Log.e(e.getMessage());
            }
            if (null != route && route.getNumSegments() > 0) {
                DataStore.saveIndividualRoute(route);
                return route.getNumSegments();
            }
        } finally {
            IOUtils.closeQuietly(stream);
        }
        return 0;
    }
Imports an GPX file containing an individual route
and stores the resulting geoitems to the route table.
(Caller needs to trigger reload and screen update.)
main/src/main/java/cgeo/geocaching/files/GPXIndividualRouteImporter.java