lundi 16 avril 2018

How to start activities depending on the database conditions in android

I’m trying to write an Android app with SQLite Database. I have 4 activites. I want to start these activities depending on specific cases in my database. This is my Database schema: enter image description here In the current situation;

…

listem.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent myintentGameA = new Intent(view.getContext(),GameA.class);

            startActivity(myintentGameA);

    }
});
 ...

I have 5 list items as you can see in my db. With the code above, when I click the first list item in my program I can start my GameA activity and I can see the numbers

2,17,24,25,3...

I want to create my other intents like this;

Intent myintentGameB = new Intent(view.getContext(),GameB.class);
Intent myintentGameC = new Intent(view.getContext(),GameC.class);
Intent myintentGameD = new Intent(view.getContext(),GameD.class);

and when I click to second list item I want to start myinentGameC activity and see the numbers

7, 14 ,23, 27, 30,..

and so on... I could not write the proper if else condition with the cursor functions. I think it should be something like this:

  • move cursor to somewhere
  • check if GameA column is null
  • if it is not null, start myintentGameA activity
  • if it is null, check if GameB column is null
  • if it is not null, start myintentGameB activity
  • if it is null, check if GameCcolumn is null
  • if it is not null, start myintentGameC activity
  • if it is null, check if GameD column is null
  • if it is not null, start myintentGameD activity

Any help would be appreciated thank you in advance.

Aucun commentaire:

Enregistrer un commentaire