Code example for Cursor

Methods: getDoublegetLong

0
        querySource(context, sourceUri, projection,
                new ContentResolverQueryCallback() { 
 
                    @Override 
                    public void onCursorResult(Cursor cursor) {
                        values.put(Images.Media.DATE_TAKEN, cursor.getLong(0));
 
                        double latitude = cursor.getDouble(1);
                        double longitude = cursor.getDouble(2);
                        // TODO: Change || to && after the default location 
                        // issue is fixed. 
                        if ((latitude != 0f) || (longitude != 0f)) {
                            values.put(Images.Media.LATITUDE, latitude);
                            values.put(Images.Media.LONGITUDE, longitude);
                        } 
                    } 
                }); 
 
        return context.getContentResolver().insert(
                Images.Media.EXTERNAL_CONTENT_URI, values);
    }