JavaFXPorts(Gluon Plugin) Saving Files on Android

大兔子大兔子 提交于 2019-12-04 04:15:47

问题


I have a problem to save Files on Android with JavaFxPorts.

I've found that link here, but it doesn't work for me.

It doesn't found the Interface, and I can't use it.

My goal is to save a file on Android with JavaFxports.

Thanks


回答1:


If you are trying to add some code in the Android folder, make sure you add correctly the GluonPlatform class in the main project. You can have a look at the GoNative sample in Gluon's sample repository, for finding out how to do it.

But to save a file in the app's local folder on your mobile device, you can use Gluon's Charm-Down open source library.

It contains common API for several platform specific services.

You just need to add it to your dependencies on the build.gradle script:

ext.CHARM_DOWN_VERSION = “1.0.0”

dependencies {
    compile "com.gluonhq:charm-down-common:$CHARM_DOWN_VERSION"
    desktopRuntime "com.gluonhq:charm-down-desktop:$CHARM_DOWN_VERSION"
    androidRuntime "com.gluonhq:charm-down-android:$CHARM_DOWN_VERSION"
    iosRuntime "com.gluonhq:charm-down-ios:$CHARM_DOWN_VERSION"
}

Save, and rebuild your project (so those dependencies are included), and now on your main project you can ask for the local path on your device, and access to the file:

public File getFile() {
    File path = PlatformFactory.getPlatform().getPrivateStorage();
    return new File(path, "config.xml");
}


来源:https://stackoverflow.com/questions/34369076/javafxportsgluon-plugin-saving-files-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!