How to update a module's view programmatically using hook_update_n? We're writing some update functions for a custom module. This custom module provides some views:

/**
 * Implements hook_views_default_views().
 */
function mymodule_views_default_views() {
  $views_dir = drupal_get_path('module', 'mymodule') . '/views';
  $views_files = scandir($views_dir);
  $views = array();
  foreach ($views_files as $filename) {
    if (substr($filename, -4) == '.inc') {
      include_once $views_dir . '/' . $filename;
    }
  }
  return $views;
}


There are several .inc files from the view export ui and all those views are provided.

Now: some of those views should be updated. We usually just export and re-import them using the view ui (and override existing views). We wondered, how would this be possible programmatically? How to tell views which files to import again and override?

function mmodule_update_7001() {
  // what goes here?
}


Thanks for any ideas!
we ended up adding the following code inside the update_n function:

  $views_dir = drupal_get_path('module', 'mymodule') . '/views';
  $views_files = scandir($views_dir);
  $views = array();
  foreach ($views_files as $filename) {
    if (substr($filename, -4) == '.inc') {
      include_once $views_dir . '/' . $filename;
      if (isset($view) &amp;&amp; is_object($view)) {
        views_save_view($view);
      }
    }
  }