How to get asset inside a extension

Hi, im try to prgramm my first Extension, but i need some help, i want the user to be able to select an Asset in the Designer e.g.

@DesignerProperty(editorType = PropertyTypeConstants.PROPERTY_TYPE_ASSET) @SimpleProperty(description = "Language File") public void langFile(String langFile) { this.langFile = langFile; }

Now i want to read that file

 if (MediaUtil.isExternalFile(path) &&
                container.$form().isDeniedPermission(Manifest.permission.READ_EXTERNAL_STORAGE)) 
{
            container.$form().askPermission(Manifest.permission.READ_EXTERNAL_STORAGE,
                new PermissionResultHandler() {
                    @Override
                    public void HandlePermissionResponse(String permission, boolean granted) {
                    if (granted) {
                        readJson(path);
                    } else {
                        container.$form().dispatchPermissionDeniedEvent(AutoI18N.this, "Json", permission);
                    }
                    }
                });
            return;
            }
            jsonPath = (path == null) ? "" : path;
            Gson gson = new Gson();
            JsonReader reader;
            try {
                reader = new JsonReader(new FileReader(jsonPath));
                Map trans = gson.fromJson(reader.toString(), Map.class);
                translations = gson.fromJson(trans.get("en").toString(), Map.class);
            } catch (FileNotFoundException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

but nothing happens, what am i doing wrong ?

1 Like

Anyone here that can help me ?
Its the only feature I don’t get to work its frustrating :sob:

you might want to ask in the Open Source Development community


Taifun