Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Does anyone have an example of how I can use SQLite in libGDX? I have a class in my original Android code that allowed me to easily access a database but I can't seem to find anything equivalent to that in libGDX. Or maybe I am missing something? Am I able to use that in the libGDX code somehow? Sorry I am new to libGDX.

share|improve this question
up vote 5 down vote accepted

If you have that, you can use (callbacks).

You define an interface, and implement the methods in the android classes, in that way you can retrieve data and get it in your proyect in libgdx.

Its an easy way.

public interface ActionPerformed 
public String actionPerformed();

public class AppActivity extends AndroidApplication implements ActionPerformed

       public AppActivity()
             new XMLProgress(this);

      public String actionPerfomed()
         //Here goes your code;

public class XMLProgress
      static ActionPerformed action;

      public XMLProgress(ActionPerformed a)
           action = a;

      public String getMethod()
          return action.actionPerformed();

I used my class in libgdx as a singleton, because i dont need a lot of instances, and i secure that is always live.

Sounds easy enough, I don't have much experience creating callbacks I guess. Can you give me a simple example, or point me to a good resource? I think once I get this working I will have a lot of uses for it other than just database calls. Thanks! – Alex_Hyzer_Kenoyer Feb 29 '12 at 22:33
Yep, wait in a moment i put some classes :P – Rudy_TM Feb 29 '12 at 22:34
The code is uploaded :D – Rudy_TM Feb 29 '12 at 22:44
Thanks a lot! I understand what you mean now, you've been such a great help! There really should be some better documentation on this subject... – Alex_Hyzer_Kenoyer Feb 29 '12 at 22:57
You are welcome, any issue, ask :D – Rudy_TM Feb 29 '12 at 23:10

If you want to use sqlite with libGdx you can use opensource project gdx-sqlite .

gdx-sqlite is a cross-platform Libgdx extension for SQLite database handling. The extension abstracts database handling to provide a unified method to handle database transacitons across multiple platforms while also adding SQLite support for desktop version of Libgdx application.

share|improve this answer

Your Answer


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.