How to pass string variable as parameter from one screen to another

My problem is similar to other related post but i want to pass “variable” not “Entity”.
i have filtered a value from table and stored it into a variable “target” now i want to pass this variable to screen2 and use “target” value for other tasks related to screen2.

I know openEditor method but it is for Entity

public Window.Editor openEditor(String windowAlias, Entity item, WindowManager.OpenType openType, Map<String, Object> params) {
WindowInfo windowInfo = windowConfig.getWindowInfo(windowAlias);
return window.getWindowManager().openEditor(windowInfo, item, openType, params);

So please suggest me some solution.

To pass your String variable you should use the last parameter of methods openEditor/openWindow - Map<String, Object> params. And the only thing you need to do is to create a map and pass it to a method:

openWindow(windowAlias, openType, ParamsMap.of("stringParam", yourVariable));

And later you can obtain the value in the init method of an opened screen:

String variable = (String) params.get("stringParam");

Best regards,