Being new in Android, I am having trouble dealing with the following:
public String[] getContacts(){
Cursor cursor = getReadableDatabase().rawQuery(\"SELECT
I hope its useful to you.
public static ArrayList SelectAll(DbHelper dbaConnection) {
ArrayList Agents_aList = new ArrayList();
SQLiteDatabase sqldb = dbaConnection.openDataBase();
Cursor cursor = sqldb.rawQuery("SELECT * FROM Agents", null);
if (cursor != null)// If Cursordepot is null then do
// nothing
{
if (cursor.moveToFirst()) {
do {
// Set agents information in model.
ModelAgents Agents = new ModelAgents();
Agents.setID(cursor.getInt(cursor
.getColumnIndex(TblAgents.ID)));
Agents.setCode(cursor.getString(cursor
.getColumnIndex(TblAgents.CODE)));
Agents.setName(cursor.getString(cursor
.getColumnIndex(TblAgents.NAME)));
Agents_aList.add(Agents);
} while (cursor.moveToNext());
}
cursor.close();
}
sqldb.close();
return Agents_aList;
}