Where does html5 libgdx app save Preferences files? - java

As I read here: https://github.com/libgdx/libgdx/wiki/Preferences
Preferences files will be saved to ~/.prefs/ (I'm on linux).
When I run desktop app, it works fine, and preferences file is saved to the right place. But with html5, it doesn't save that file! I'm sure it was saved somewhere, because the game still can read it (it contains scores).
My code is really simple, just:
Preferences score = Gdx.app.getPreferences("Highscore");
score.putInteger("score", _points);
score.flush();
I built the game by running
./gradlew html:dist
and run it on localhost created by python
python -m SimpleHTTPServer
then go to http://localhost:8000 on Firefox.
Anyone could help? Thanks for reading, have a nice day.

I found my .prefs in my libgdx html game by running the game in Chrome, right clicking and choosing Inspect Element, clicking on the Resources tab, expanding the Local Storage tab, and examining the entry https://myAppName. This is where the .prefs are kept...

Related

How To Open Files With .Jar (Java) Application?

Tough question here. How do you open a file in java, in the way that when you double click on the file it automatically opens in a java application.
I'm making a musicplayer (first real big Java project for me) and I have no clue how to acheive this. When you open, lets say, a .mp3 file it will open in whatever default program you have selected for it (such as VLC mediaplayer or Windows Media Player). What I want is to be able to set the .jar file of my application as the default program for .mp3 files, and then to be able to actually launch the files in the application.
When I currently try to open a file with the application I get a windows error saying "This app cannot be executed on your pc". But when I launch the .jar itself without doing it by trying to open a .mp3 file it runs just fine.
Does anyone know how to acheive what I want? Many thanks in advance!
---edit---
I do not mean that you can select a default program for the mp3 file. The problem is that windows throws the error shown above, and that I dont know how to handle the application being launched by opening a file (which does not ope due to the error).
I think the problem is that you have to open a file with a .exe , so you sshould use an exe wrapper (I use jsmooth: download here)
BUT, before you do that, you need to accept that info. So in the main class, the "args" is a list of info about how it's being launched. If you are opening a file, the array's first argument will be the opened file's destination. SO I would accept it like this:
if (args.length > 0) {
File f = new File(args[0]);
start_the_application_with_a_file(f);
} else {
start_the_application_without_a_file();
}
C:\ProgramData\Oracle\Java\javapath\java.exe -jar "C:\Program Files\YourApp.jar" %* within a batch-file (.cmd) might do it.

Where to find the created file in Android emulator in Windows

I created a simple file write/read app in Eclipse and have successfully tested that it could read what it wrote. The structure is fairly simple. I use FileOutputStream to write a samplefile.txt using openFileOutput and a FileInputStream using openFileInput to read it back. The only minor thing is that I don't know where is the file on my physical hard drive? Can anybody point me to where I could find the file in Windows?
If you dont give a absolute path the file will be creataed in aplication directory.
This is /data/data/packge-name-of-your-app/
e.g:
/data/data/com.example.test/
See more http://developer.android.com/training/basics/data-storage/files.html
Go to DDMS perspective, select the emulator which you are using, go to package explorer tag ,then you will get a list of folders hierarchy.
Go to /data/data/
Now you will see a list of packages installed, search for the package name of your app and expand it.
Here you will see the files which your application created when it was running.
P.S : You cannot find this file on the physical drive of your computer,because it is present in the storage of the emulated android virtual device. This storage cannot be directly accessed by you.

I can not see with db Questoid SQLite Browser

i am using eclipse for android programing and now i need to view SQLite database in the emulator.
I followed these step:
Download .jar file
Place the plugin .jar file in your Eclipse plugins folder (e.g. /usr/lib/eclipse/plugins)
Restart Eclipse
Start up an Android Emulator w/ Debugging in Eclipse
Switch to the DDMS Perspective in Eclipse
Go to the 'File Explorer' tab to locate your device's database file
Navigate to: e.g. 'data -> data -> com.myproject -> databases -> myproject
Now when i try to Open the database file in Questoid i can't select it!
(see screen shot)
same advice?
From your screen shot there, the database does not have a "." (read: period) in the file name & extension area.
Improper: mydatabaseDB
Proper: mydatabase.db
Once the database shows the proper extension (and is a proper SQLite database), then Questoid will (I use the plugin all the time in Eclipse (Juno version)) then show the "active" button (not disabled like in your screen shot). When looking for latest database entries (what was just added into the database), I then click once again on the toolbar icon as you show there, in the upper right of the screen. I then go to the Browse Data tab for that view, then choose the table from the database I want to view the fields from.
I hope this helps.
Happy coding...
I had the same problem with "sqlitemanager": only .db-Database files are accepted.
This is the solution:
Download this Questoid SqLiteBrowser: http://www.java2s.com/Code/JarDownload/com.questoid/com.questoid.sqlitebrowser_1.2.0.jar.zip
Unzip and put it into eclipse/dropins (not Plugins)
Try following these steps:
1) Close Eclipe
2) Remove the .jar from /usr/lib/eclipse/plugins.
3) Place the .jar in /eclipse/dropins and let Eclipse try to install it for you.
4) Start Eclipse.
you can always use sqlitebrowser externally . You will have to pull your databse everytime from ddms though .
The file has to end with .db extension, so the answer is to name your database as this sqlite browser expects it to be.
Another way of fixing it is to find a year old version that does not have this constraint.
Please use the extension ".db" in lowercase, please don't try with these extensions .SLQLITE, .BD, .DB, .SQL, or similar or without extensions.
Regards,

Change Java temporary internet files storage location

I am trying to change the storage location of Java Web Start. I read that the location is changeable through the java control panel. I got there and I can see the path of my "temporary internet files" but the "change" button is gray. Why can't I change this path? I need to change it to another hard drive.
I googled it for you.
This was my search phrase:
java console change temporary location
And this was the result that was most appropriate:
How to change Cache location for Java on windows 7
Step 1
Find javacpl.exe in C:\Program Files (x86)\Java\jre1.8.0_31("newest version")\bin*javacpl*
Step 2
Right click on javacpl than Properties---Compatibility---choose
run this program in compatibility mode for “Windows XP SP3″
Step 3
Go to
Control panel--Java--General--Setting--Location and Change it.
P.S. Close java control panel before step 1 if its open.

How to auto-launch a jar file?

I have a game on a USB drive called MyGame.jar.
It is an executable jar file. I want to be able to put it on cd's and USB drives.
I want the game to start up automatically when the cd or USB is put into the computer, how can i do this?
The game will only be ran on Windows based computers(Windows Xp & Windows 7).
Creating an autorun.inf (Autorun.inf entries) will work quite nicely for a CD.
But for USB drives, as of Windows 7, it can't be done. Microsoft disabled this "feature" because of all the malware that auto-installed that way...
In your case, the contents of autorun.inf should be something like this:
[autorun]
shellexecute=MyGame.jar
icon=MyIcon.ico
label=MyGameName
shellexecute opens MyGame.jar automatically using the jre (if installed). The other lines are optional but good practice.
Here's how to automatically launch an application using autoplay:
Make a text file and save it as autorun.inf. Save it in the base path of the CD.
The contents of autorun.inf should look something like this:
RUN=setup.exe
Icon=icon.ico
The icon field is optional.
Note that this only works if the user has autoplay enabled. If the user disabled it, it won't work.

Categories