我正在尝试在我的数据库中创建一个方法。我想从我的数据库中返回一个具有特定列名的特定行中的字符串。我试过这个,但它不起作用。有人能帮助我吗??
public String getNameAtPosition(String row){
String name = null;
Cursor c = mDb.query(ValuteMetaData.VALUTE_TABLE, null, ValuteMetaData.ID + "=" + row, null, null, null, null);
name = String.valueOf(c.getLong(ValuteMetaData.VALUTE_NAME_KEY));
return name;
}
public Cursor fetchValuteListView(String data){
String[] data_query={data};
return mDb.query(ValuteMetaData.VALUTE_TABLE,null,ValuteMetaData.VALUTE_DATA_KEY+"=?",data_query,null,null,null);
}
static class ValuteMetaData { // i metadati della tabella, accessibili ovunque
static final String VALUTE_TABLE = "Valute";
static final String ID = "_id";
static final String VALUTE_NAME_KEY = "name";
static final String VALUTE_SIGLA_KEY = "sigla";
static final String VALUTE_CAMBIO_KEY = "cambio";
static final String VALUTE_DATA_KEY = " data";
}
private static final String VALUTE_TABLE_CREATE = "CREATE TABLE IF NOT EXISTS " //codice sql di creazione della tabella
+ ValuteMetaData.VALUTE_TABLE + " ("
+ ValuteMetaData.ID+ " integer primary key autoincrement, "
+ ValuteMetaData.VALUTE_NAME_KEY + " text, "
+ ValuteMetaData.VALUTE_SIGLA_KEY + " text, "
+ ValuteMetaData.VALUTE_CAMBIO_KEY + " text, "
+ ValuteMetaData.VALUTE_DATA_KEY + " text);";