Android Not saving/reading ini files on Android

K

kookamango

Guest
Hi all,

I'm not able to save or read high scores on android. Well, I'm not able to read them for sure. I do see 4kb in app data after I run the save script, but am not able to load it. Here is my code:

Object create event:
Code:
//file=working_directory + "\savegame.ini"
file="savegame.ini"
ini_open(file) //begin saving
    global.head=ini_write_real("base","head",0)
    global.armor=ini_write_real("base","armor",0)
    global.weapon=ini_write_real("base","weapon",0)
    global.difficulty=ini_write_real("base","difficulty",0)
    global.best=ini_write_real("base","best",0)
    global.gold=ini_write_real("base","gold",0)
ini_close()
Object destroy event:
Code:
//file=working_directory + "\savegame.ini"
file="savegame.ini"
ini_open(file) //begin saving
    ini_write_real("base","head",global.head)
    ini_write_real("base","armor",global.armor)
    ini_write_real("base","weapon",global.weapon)
    ini_write_real("base","difficulty",global.difficulty)
    ini_write_real("base","best",global.best)
    ini_write_real("base","gold",global.gold)
ini_close()
As you can see from the commented out lines, I've tried other formats for saving the data, without success. Any ideas?
 

Nocturne

Friendly Tyrant
Forum Staff
Admin
Try with simply:

ini_open("savegame.ini")

Other than that it all looks okay...
 

Alexx

Member
Code:
//for saving values to an INI file
file="savegame.ini"
ini_open(file) //begin saving
    ini_write_real("base","head",global.head)
    ini_write_real("base","armor",global.armor)
    ini_write_real("base","weapon",global.weapon)
    ini_write_real("base","difficulty",global.difficulty)
    ini_write_real("base","best", global.best)
    ini_write_real("base","gold",global.gold)
ini_close()
Code:
//for loading values from an INI file
file="savegame.ini"
ini_open(file) //begin loading
    global.head=ini_read_real("base","head",0)
    global.armor=ini_read_real("base","armor",0)
    global.weapon=ini_read_real("base","weapon",0)
    global.difficulty=ini_read_real("base","difficulty",0)
    global.best=ini_read_real("base","best",0)
    global.gold=ini_read_real("base","gold",0)
ini_close()
This assumes all the global variables you listed are real values and not strings.
 
Last edited:
I

ItchyPancake

Guest
Make sure you go to android settings and enable the permission to read/write to device.

That's assuming you have not tried that of course, just bringing in potential options
 
K

kookamango

Guest
hmm thanks for the input so far guys. So far nothing special, but I did find the ini file.

The file reads:
Code:
[base]
head="0.000000"
armor="0.000000"
weapon="0.000000"
difficulty="0.000000"
best="0.000000"
gold="0.000000"
It looks like maybe the values are being loaded and set to the default, but never overwritten during the save event?
 
K

kookamango

Guest
ah haha oh my god just saw your last posts... thanks for catching that. I'm feeling super smart
 
Top