Aaron Stein
Aaron Stein

Reputation: 526

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.

Error

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

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

Thanks

Upvotes: 3

Views: 1664

Answers (1)

José Pereda
José Pereda

Reputation: 45456

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

Upvotes: 4

Related Questions