-1

I have permission already

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

but open failed: 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();
    }
NobodyNada
  • 7,529
  • 6
  • 44
  • 51

1 Answers1

1
No such file or directory

The file you're trying to access doesn't exist. I would check the code where you build your file path, and make sure that it's a valid file path to external storage

Jeeter
  • 5,887
  • 6
  • 44
  • 67