how to refresh workspace using API and java code
<p>i have just added a new package to my project via code. now i need to access the files from this project. i cant access the files that i have added as the workspace is out of sync with the changes. so i need to refresh the workspace.</p>

<p>i have written the following code. but it is not working. can somebody have a look at it n suggest me how to do it properly.</p>

<pre><code> private void setScreen2Next() throws CoreException {
    System.out.println("NEXT BUTTON--SCREEN2");
    mainScreen=false;
    screen2=false;
    screen3=true;
    nameField.hide();
    //disableScreen2();
    addModule(); //new module added to the workspace
    nextButton.setLabel("Next=&gt;");
    refreshWorkspace();//Resources become out of sync with the workspace if they are changed directly in the file system without using Eclipse workspace API. so refresh them
    repaint();
}

  private void refreshWorkspace() throws CoreException {

     IWorkspace workspace = ResourcesPlugin.getWorkspace();
        IWorkspaceRoot root = workspace.getRoot();
        root.refreshLocal(IResource.DEPTH_ZERO, null);
}
</code></pre>

<p>it is begin used here [if it helps]</p>

<pre><code>   private void setScreen3(Graphics g) throws CoreException {
    System.out.println("in screen3");
    //disableScreen2();
    backButton.disable();
    g.drawString("Kindly select attributes and methods that you wish to keep in class 'Description'", 50, 50);
    nameField.hide();
    nextButton.setLabel("Create");
    loadAnM("Description.java"); //loading the file Description.java from the recently added module [addModulle()]

}
</code></pre>

<p>================================================================</p>

<p>nevermind....i found the answer to my question. problem was with </p>

<pre><code>    root.refreshLocal(IResource.DEPTH_ZERO, null);
</code></pre>

<p>.DEPTH_ZERO mean just refresh root, not all its members</p>

<p>to solve this issue, i changed it to </p>

<pre><code>   root.refreshLocal(IResource.DEPTH_INFINITE, null);
</code></pre>

<p>.DEPTH_INFINITE will refresh all its children to their max depth</p>
