Jump to content
  • Advertisement
Sign in to follow this  
Philip Borgstr

Code only works on desktop

This topic is 2181 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

package com.philipborg.aol;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Properties;

import com.badlogic.gdx.Gdx;

public class Settings {
	public static boolean soundEnabled = true;
	public final static String file = "AOL/settings.txt";
	static Properties prop = new Properties();

	public static void load() {
		BufferedReader in = null;
		try {
			in = new BufferedReader(new InputStreamReader(Gdx.files.external(
					file).read()));
			prop.load(in);
			soundEnabled = Boolean.parseBoolean(prop.getProperty(
					"soundEnabled", "true"));
			Gdx.app.log("Settings - load", "Loaded settings");

		} catch (Throwable e) {
			// Switches to default
			Gdx.app.log("Settings - load", "Could not load settings");
		} finally {
			try {
				if (in != null)
					in.close();
				save();
			} catch (IOException e) {

			}
		}
	}

	public static void save() {
		BufferedWriter out = null;
		try {
			out = new BufferedWriter(new OutputStreamWriter(Gdx.files.external(
					file).write(false)));
			prop.setProperty("soundEnabled", Boolean.toString(soundEnabled));
			prop.store(out, "AOL SETTINGS");
			out.close();
		} catch (Throwable e) {
		} finally {
			try {
				if (out != null)
					out.close();
			} catch (IOException e) {
			}
		}
	}

}

This LibGDX code somehow only works on desktop. I want it to work on Android as well since I do not really care about HTML support.This code is my full settings class and is in it's native form. What do I need to do to make it work on Android?

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!