данные не присваиваются адаптеру
Добавлено: 29 июл 2014, 11:07
Код: Выделить всё
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
DBHelper dbh = new DBHelper(this);
SQLiteDatabase db = dbh.getWritableDatabase();
Cursor cursor = db.query("Kontant", null, null, null, null, null, null);
startManagingCursor(cursor);
String[] childFrom = {"name"};
int[] childTo = {R.id.tv};
ListView lvMain = (ListView) findViewById(R.id.lvMain);
SimpleCursorAdapter scAdapter = new SimpleCursorAdapter(this, R.layout.item, cursor, childFrom, childTo);
lvMain.setAdapter(scAdapter);
}
class DBHelper extends SQLiteOpenHelper {
public DBHelper(Context context) {
super(context, "myDB", null, 1);
}
public void onCreate(SQLiteDatabase db) {
db.execSQL("create table Kontant ("
+ "id1 integer primary key autoincrement,"
+ "name text"
+ ");");
db.execSQL("create table phone ("
+ "id2 integer,"
+ "name text"
+ ");");
}
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
А где это ошибка не догоняю