简体   繁体   English

JavaFXPorts(Gluon插件)在Android上保存文件

[英]JavaFXPorts(Gluon Plugin) Saving Files on Android

I have a problem to save Files on Android with JavaFxPorts. 我在使用JavaFxPorts在Android上保存文件时遇到问题。

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. 我的目标是使用JavaFxports在Android上保存文件。

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. 如果您尝试在Android文件夹中添加一些代码,请确保在主项目中正确添加GluonPlatform类。 You can have a look at the GoNative sample in Gluon's sample repository, for finding out how to do it. 您可以查看Gluon示例存储库中的GoNative 示例 ,以了解如何执行此操作。

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. 但是要将文件保存在移动设备上应用程序的本地文件夹中,您可以使用Gluon的Charm-Down开源库。

It contains common API for several platform specific services. 它包含几种特定于平台的服务的通用API。

You just need to add it to your dependencies on the build.gradle script: 您只需将它添加到build.gradle脚本的依赖build.gradle

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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