I have an application that stores information in a database based on the information from 5 text fields. I'm having trouble being able to sort through fields or just even sorting from one field. Also, what method does the ORDER BY clause go in? Snippets of code for the database is below:
public static final String MYDATABASE_NAME = "MY_DATABASE";
public static final String MYDATABASE_TABLE = "MY_TABLE";
public static final int MYDATABASE_VERSION = 1;
public static final String KEY_CONTENT = "Content";
public static final String lastName = "lastName";
public static final String firstName = "firstName";
public static final String school = "school";
public static final String email = "email";
public static final String intrest = "intrest";
Cursor d = sqLiteDatabase.rawQuery("SELECT * from " + MYDATABASE_TABLE + "ORDER BY " + lastName + " ASC" , null);
while (d.moveToNext()) {
int sort = d.getColumnIndex(lastName);
int sort2 = d.getColumnIndex(intrest);
String lastName = d.getString(sort);
String intrest = d.getString(sort2);
System.out.println("GOT STUDENT " + lastName + " LIKES " + intrest);
}