我无法在我正在处理的应用上检索我的sd上的图像路径。我已经尝试使用setImageDrawable方法以及setImageURI方法,似乎都没有在我的SD卡上显示图片。 picpath的数据库字段是一个字符串字段,只指向我SD卡上的文件。我的堆栈跟踪中出现运行时标准运行时异常错误。代码如下:
public void DisplayAllStudents(){
DBAdapter db = new DBAdapter(this);
db.open();
Cursor c = db.getAllStudents();
if(c.moveToFirst()){
do{
String stuName = c.getString(c.getColumnIndex(db.KEY_STUDENTNAME));
String stuDOB = c.getString(c.getColumnIndex(db.KEY_DOB));
results.add(" " + stuName.toString() + ", D.O.B: " + stuDOB);
ImageView imgView = (ImageView) findViewById(R.id.studenticon);
imgView.setImageDrawable(Drawable.createFromPath(strPathToPic));
//display record
DisplayStudent(c);
}while(c.moveToNext());
}
//bind data to list view
list.setAdapter(new ArrayAdapter<String>(StudentTrackerActivity.this,R.layout.datalayout,R.id.txtFname,results));
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v, int position,
long id) {
String item = list.getItemAtPosition(position).toString();
Toast.makeText(getApplicationContext(), item, Toast.LENGTH_LONG).show();
}
});
db.close();
}