Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

In Flash, for example, I can place an xml file along with the binary, then if I modify some variable the game will change for everyone.

How to achieve something like that in Android? I know that for every change I make to the game, the player would need to download a new update.

But the main goal I'm looking for, is modifying a game stats without the need for recompile the entire APK.

I'm working with Haxe+OpenFL.

share|improve this question

3 Answers 3

You can either store the settings in a database connected to your application or save them on the SD card.

The integrated databases are assigned to a certain application and only this application cann access them. So you can save them there even though only the application can change them.

The other way would be to use the SD card (or other external memory) and save them there. Access to the SD card is possible for each application so anyone could change the settings then.

To create or change the settings create a service in your application that queries this settings from an external server.

share|improve this answer
    
How does that work with the update system on Android? If I change something in the database, then update the app on the store, does the user get that update? –  Veehmot Aug 5 '13 at 14:57
    
The database is local to the device. So you can change this from the app itself (without going over the shop). You simply have to inform your app about this (e.g. by asking a server at the start of the app). –  Uwe Plonus Aug 6 '13 at 5:27

You can use a SQLite database, but it has to be on your SD card or on your device. Here is the reference for SQLite on Android: http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#openDatabase

However you may be able to download the file to your SD card, check out this URL where someone downloaded an image to their SD card: http://stackoverflow.com/questions/3296850/how-do-i-transfer-an-image-from-its-url-to-the-sd-card

share|improve this answer

I'm loading a local file from SD card (Android 4.3) like that:

// loading local file
#if android
loadTextFromURL( "/sdcard/PROjekty/testHaxe.txt" );
#end
#if flash
loadTextFromURL( "file:///C:/O/PROjekty/testHaxe.txt" );
#end
#if windows
loadTextFromURL( "C:/O/PROjekty/testHaxe.txt" );
#end
...

// loading file over http
loadTextFromURL( "http://oskarswierad.com/temp/testHaxe.txt" );
...

public function loadTextFromURL( address:String ):Void {
    var newLoader:URLLoader = new URLLoader();
    newLoader.dataFormat = URLLoaderDataFormat.TEXT;
    newLoader.addEventListener( Event.COMPLETE , textLoaded );

    newLoader.load( new URLRequest( address ) );
}
...

public function textLoaded( evt:Event ):Void {
    var text:String = cast(evt.target, URLLoader).data;

    trace( text );

    evt.target.removeEventListener( Event.COMPLETE , textLoaded );
}

You'll need to find out how to get path to SD card dynamically. I mean on every device model or system version the path can be different.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.