I'm trying to make SELECT
below passing a value as a parameter in the search, but it still gives the same error.
android.database.sqlite.SQLiteException: near "SQL": syntax error (code 1):, while compiling: SQL * FROM Employers WHERE id =?
What is the problem with my SELECT
?
public Employer getEmployerProfile(String parameter) {
String sql = "SQL * FROM Employers WHERE id = ?";
SQLiteDatabase db = getReadableDatabase();
Cursor c = db.rawQuery(sql, new String[]{parameter});
c.moveToFirst();
Employer employerProfile = new Employer();
employerProfile.setName(c.getString(c.getColumnIndex("name")));
employerProfile.setAddress(c.getString(c.getColumnIndex("address")));
return employerProfile;
}
Format the fields in the table:
private String createTableEmployers() {
String sql = "CREATE TABLE Employers (id INTEGER PRIMARY KEY, name TEXT NOT NULL, email TEXT NOT NULL, address TEXT, status TEXT, confirmationStatus TEXT)";
return sql;
}