简体   繁体   中英

JavaFXPorts(Gluon Plugin) Saving Files on Android

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

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");
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM