0
\$\begingroup\$

I want to know if I can just implement sqlite database for android in libgdx game? Also if this is not possible then may I know the simple way to integrate libgdx game to just store scores in sqlite database. I dont want to use preference or jason because I have to get last stored scores and then level wise comparison of scores.

\$\endgroup\$

closed as too broad by Josh Dec 22 '14 at 18:51

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Questions asking "is it possible" are yes-or-no questions, which are generally poor questions for the SE format. The implicit follow up ("how can I...") is too broad with the limited information you've provided and probably isn't particularly game-development specific anyway (so should be asked on SO). \$\endgroup\$ – Josh Dec 22 '14 at 18:52
  • \$\begingroup\$ Ók. I am new here so I was not knowing how to ask. Thank you for pointing out my mistakes. \$\endgroup\$ – Aiman Batul Dec 23 '14 at 4:19
0
\$\begingroup\$

To use platform specific code in libgdx you make an interface in your core project.


interface SaveScore {
   public void saveScore(int score);
}

And then make an implementation in your android project and any other projects you might have (desktop, ios and so on).


public class SaveScoreAndroid implements SaveScore {
    public void saveScore(int score) {
        //Platform specific code goes here
    }
}

Then you make your application listener take in an implementation of the interface as an argument in the constructor. Now you can pass in the platform specific implementation of the interface in the starter class of your android project.

protected void onCreate (Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
    initialize(new MyGame(new SaveScoreAndroid()), config);
}
\$\endgroup\$

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