samedi 7 mars 2015

Retrieve specific rows from sqlite database depending on chosen value

So I have a sqlite database in my assets that I use to populate a ListView. Depending on the value select by the user from a spinner I show the values of a table, this part is ok!


Now depending of the time chosen in another spinner (it goes from 7:”” ; 8:”” ; 9:”” and so on) I want to retrieve the values of the row that contain those values .


I tough in given a integer in the sqlite table so that 7hour= 7; 8hour = 8 so that it would be easier to retrieve the values, but I am not getting how to do this.


So how can I get only a specific rows from a select value? And can set it programmatically to get intermediate values. Like if user select 8:00 in first spinner and 24:00 in second can I show the values betweenthat from without having so setting it all manually


So if possible i want to get this:



if (spinnervalue.equals(blah) ){­ retrieve a table
if (spinnertimeselect.equals(7:00))
{filter values so that only rows with 7:00 appears
}
}


and if possible this also



if (spinnervalue.equals(blah)) {­ retrive a table
if (firstspinnertimeselect.equals(8:00) && secondspinnertimeselect.equals(24:00))
{filter values so that only rows bettwen 8:00 and 24:00 appears or 17:00 and 20:00 for example
}
}


My SimpleCursorAdapter



customTravelListView.setAdapter(new SimpleCursorAdapter(getActivity().getApplicationContext(),
R.layout.main_customtravel_listview, getScheduleCursor,
new String[]{PARTIDA, AUTOCARRO, CHEGADA, POR_EN},
new int[]{R.id.departure, R.id.bus, R.id.arrival, R.id.note}, 0));


Part of the table with an example of wath i am doing.


Part of my Table


I am using http://ift.tt/1onWUjW for creting the database and http://ift.tt/1dBxfAL as the asset helper.


Aucun commentaire:

Enregistrer un commentaire