Before I added in “order by”, my statement works well and data is able to be displayed. After I added “order by”, it is unable to work! Is there some thing wrong with my statement?
Cursor c = sampleDB.rawQuery("SELECT companyNameEng FROM " +
TABLE_NAME + "ORDER BY companyNameEng asc", null);
if (c != null ) {
while (c.moveToNext()) {
womenName.add(c.getString(0)); // Get the current subj
// code, add to list
}
sampleDB.close();
}
sampleDB.close();
Knowing exactly how it fails would help us answer the question, but a guess is that you are missing a space character before the “ORDER BY” part of your statement. Unless
TABLE_NAMEincludes a trailing space, this will make for an invalid SQL statement.