我已经有权限了
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
但打开失败:ENOENT (No such file or directory)
try {
dbmanager = new DBManager(this);
sqlitedb = dbmanager.getReadableDatabase();
Cursor cursor = sqlitedb.query("photos", null, null, null, null, null, "title");
int i = 0;
while(cursor.moveToNext()) {
String str_title = cursor.getString(cursor.getColumnIndex("title"));
String str_orientation = cursor.getString(cursor.getColumnIndex("orientation"));
String str_background = cursor.getString(cursor.getColumnIndex("background"));
String str_path = cursor.getString(cursor.getColumnIndex("path"));
LinearLayout layout_list = new LinearLayout(this);
layout_list.setOrientation(LinearLayout.HORIZONTAL);
layout_list.setPadding(20, 10, 20, 10);
layout_list.setId(i);
layout_list.setTag(str_title);
ImageView iv_photo = new ImageView(this);
Uri uriFromPath = Uri.fromFile(new File(str_path));
Bitmap bitmap = null;
try {
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uriFromPath));
Bitmap thumb = Bitmap.createScaledBitmap(bitmap, 200, 200, true);
iv_photo.setImageBitmap(thumb);
layout_list.addView(iv_photo);
} catch (FileNotFoundException e) {
Toast.makeText(this, "error: " + e.getMessage(), Toast.LENGTH_LONG).show();
}