Getting data from particular number of rows
Please have a look at the following code
public List getWordList(int listNumber) {
// TODO Auto-generated method stub
List<String> list_a = new ArrayList<String>();
List<String> wordList = new ArrayList<String>();
int counter = 0;
try
{
String selectQuery = "select * from WordList";
Cursor cursor = database.rawQuery(selectQuery, null);
if(cursor.moveToFirst())
{
do
{
String englishWord =
cursor.getString(cursor.getColumnIndex("EnglishWord"));
String portugueseWord =
cursor.getString(cursor.getColumnIndex("PortugueseWord"));
String englishHint =
cursor.getString(cursor.getColumnIndex("EnglishHint"));
String portuguestHint =
cursor.getString(cursor.getColumnIndex("PortugueseHint"));
list_a.add(englishWord);
list_a.add(portugueseWord);
list_a.add(englishHint);
list_a.add(portuguestHint);
}
while(cursor.moveToNext());
//Toast.makeText(context, "Data Retrieved:
"+branches.get(1), Toast.LENGTH_LONG).show();
}
cursor.close();
return list_a;
}
catch(Exception e)
{
Toast.makeText(context, "Exception: "+e.getLocalizedMessage(),
Toast.LENGTH_LONG).show();
return null;
}
}
Here, I am getting the data from the first row to last row. But, this is
not what I need. If the 'number', the parameter is 1, I need data from row
0-9, if the 'number' is 2, I need data from row 10-19 if the 'number' is
3, I need data from row 20-29 like wise.
I am not familiar with SQLite, so how can I do this?
Please help.
No comments:
Post a Comment