简体   繁体   English

更改libgdx首选项位置

[英]Changing libgdx preferences location

I'm saving my data in preferances with libgdx, but when I export project to android it doesnt export with preferences. 我用libgdx将我的数据保存在preferances中,但是当我将项目导出到android时,它不会导出首选项。 How do I save preferences to project folder location so that when I export my project it goes with it? 如何将首选项保存到项目文件夹位置,以便在导出项目时它可以使用它?

stats = Gdx.app.getPreferences("Stats");

if I understand what you want to do, and want to use the preferences, you can create a class to be in charge, to prove in the first execution of the program if the file exists preferences and if not so, a method that being entrusted to run creating the file. 如果我理解你想做什么,并想要使用首选项,你可以创建一个负责的类,在程序的第一次执行中证明文件是否存在首选项,如果不是,则委托方法运行创建文件。 with default preferences. 使用默认首选项。

you could also copy the file you have preferences within the asset folder and read this file and then use Gdx.files.local ("yourFilesCopy"); 你也可以在资产文件夹中复制你有偏好的文件,然后阅读这个文件,然后使用Gdx.files.local ("yourFilesCopy"); to copy/save in this path, it, but I think it would be better to create as I said each first execution. 它可以复制/保存在这条路径中,但我认为按照我说的每次首次执行来创建会更好。

in this link you can see more, also you can see where the file is saved depending on OS you're using: 在此链接中,您可以看到更多内容,您还可以根据您使用的操作系统查看文件的保存位置:

https://github.com/libgdx/libgdx/wiki/Preferences https://github.com/libgdx/libgdx/wiki/Preferences

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

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