我想在数据库中获取一些数据,这些数据提供给arrayadapter然后我放入列表视图,但我看到"内存不足"
infoActivity:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.ly_info);
try {
list_info=(ListView)findViewById(R.id.list_info);
dbHelper d = new dbHelper(getApplicationContext());
liste=d.getAllInfo();
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
infoActivity.this,
android.R.layout.simple_list_item_1,
liste );
list_info.setAdapter(arrayAdapter);
} catch (Exception e) {
// TODO: handle exception
}
DbHelper:
public ArrayList getAllInfo()
{
ArrayList listeInfo = new ArrayList();
String sql ="SELECT * FROM asd";
SQLiteDatabase db = this.getReadableDatabase();
Cursor c=db.rawQuery(sql, null);
while(c.moveToFirst())
{
int shortNameColumnIndex = c.getColumnIndexOrThrow ("shortName");
int longNameColumnIndex = c.getColumnIndexOrThrow ("longName");
String gelenShort=c.getString(shortNameColumnIndex);
String gelenLong=c.getString(longNameColumnIndex);
listeInfo.add(gelenShort+": "+gelenLong);
}
return listeInfo;
}