0
你好,我保存在我的數據庫圖像的路徑。如何在屏幕上顯示圖像?圖像路徑保存在表「 contactTest1「! 現在我可以在我的屏幕上顯示圖像的唯一的路徑,這樣每個聯繫人:從數據庫中顯示圖像,你保存圖像的路徑
我用這個在dbconsole.java:
private static String[] FROM = { DbConstants.NAME, DbConstants.PHOTO, DbConstants.EMAIL,DbConstants.URL_STRING,DbConstants.ADRESS,DbConstants.PHONE,_ID};
private static int[] TO ={R.id.name,R.id.edittext1};
private void showContacts(Cursor cursor) {
//set up data binding
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.item, cursor, FROM, TO);
setListAdapter(adapter);
這
我用它來獲取代碼圖像路徑:
Button sButton = (Button) findViewById(R.id.button1);
sButton.setOnClickListener(new OnClickListener() {
public void onClick(View arg0) {
// in onCreate or any event where your want the user to
// select a file
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent,
"Select Picture"), SELECT_PICTURE);
}
});
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == RESULT_OK) {
if (requestCode == 1) {
// currImageURI is the global variable I'm using to hold the content:// URI of the image
Uri currImageURI = data.getData();
getRealPathFromURI(currImageURI);
}
}
}
public String getRealPathFromURI(Uri currImageURI) {
// can post image
String [] proj={MediaStore.Images.Media.DATA};
Cursor cursor = managedQuery(currImageURI,
proj, // Which columns to return
null, // WHERE clause; which rows to return (all rows)
null, // WHERE clause selection arguments (none)
null); // Order-by clause (ascending by name)
int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
cursor.moveToFirst();
poza=(EditText)findViewById(R.id.editText1);
poza.setText(currImageURI.toString());
return cursor.getString(column_index);
}
應該說,這就是如果你決定不在數據庫中存儲一個blob。 – barry 2011-12-30 17:42:20
jonny - 你最終做了什麼?你解決了這個問題嗎? – 2013-08-27 19:15:07