Loading tags after opc ua device restart

I am developing a custom module based on the OPC UA device example. When a device is running, folders and tags are created. When the device gets disabled, all tags are set to bad quality. When i enable the device, i have to delete it in the Tag Browser in the designer and put it in again so that the tags and folders are updating. This is because i always create new instances of folders and tags in my module. Instead i want that the tags work without dragging the device again and again into the tag browser. In my onStartup i try to get all tags with this approach:

  dataItems = deviceContext.getSubscriptionModel().getDataItems(deviceContext.getName());

but dataItems is always empty, i also tried to get the references but nothing worked out.
this is what happens in the onShutdown (when device gets disabled or deleted):

private void onShutdown() {
        deviceContext.getSubscriptionModel()
                .getDataItems(deviceContext.getName())
                .forEach(item -> item.setQuality(new StatusCode(StatusCodes.Uncertain_LastUsableValue)));
        subscriptionModel.shutdown();
        deviceContext.getGatewayContext()
            .getExecutionManager()
            .unRegister(EuromapDeviceType.TYPE_ID, deviceContext.getName());
        euromapDataMonitor.stopFileWatch();
    }

How can i use the folders and tags that were created at the first start of the device?

This is the approach used by all the other drivers too. It shouldn't be empty, it should have any existing DataItem created by any client, and represents the things your driver needs to poll or otherwise update after it starts.

You shouldn't need to be dragging and dropping tags from the OPC browser to the Tag browser again.

Is there a way to convert the Data Items to a UaVariableNode so that i can update the values etc. ?

Sorry that question just doesn't make any sense.

Regardless of what Data Items exist, you should be creating the same Nodes every time your driver starts. The Nodes represent the data your driver is making available.

Data Items (Monitored Items) represent a request from a client to sample/monitor a particular attribute of a particular node.