First note is code works just fine with lower quality images, however when a user uses an image that they took with their phone camera at higher quality the image dose not show up in the application. Lower quality images do however. Can someone please explain why this is happening and the best way to code a fix for this?

ImageDatabaseHandler.java (relevant code only)

```
public Boolean deleteItem(Integer id) {
    SQLiteDatabase db = this.getWritableDatabase();
    String table = "images";
    String whereClause = "id=?";
    String[] whereArgs = new String[]{String.valueOf(id)};
    db.delete(table, whereClause, whereArgs);
    return true;
}

public Boolean insertimage(String x, Integer i) {
    SQLiteDatabase db = this.getWritableDatabase();
    try {
        FileInputStream fs = new FileInputStream(x);       
        byte[] imgbyte = new byte[fs.available()];
        fs.read(imgbyte);
        ContentValues contentValues = new ContentValues();
        contentValues.put("id", i);
        contentValues.put("img", imgbyte);
        db.insert("images", null, contentValues);
        fs.close();
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}

public Bitmap getimage(Integer id) {
    SQLiteDatabase db = this.getWritableDatabase();
    Bitmap bt = null;
    Cursor cursor = db.rawQuery("select * from images where id=?", new String[]{String.valueOf(id)});
    if (cursor.moveToNext()) {
        byte[] imag = cursor.getBlob(1);
        bt = BitmapFactory.decodeByteArray(imag, 0, imag.length);

    }
    return bt;
}

```

MyActivity (relevant code only)

```
int stockNumber = 0;

Button insert, delImg;
EditText number;
ImageView imageView;
ImageDatabaseHandler db;
private static final int PICK_IMAGE = 100;

protected void onCreate(Bundle savedInstanceState) {
....
insert = findViewById(R.id.SetImage);
    imageView = findViewById(R.id.imageView);

    db = new ImageDatabaseHandler(this);
    insert.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent intent = new Intent(Intent.ACTION_PICK, Uri.parse(
                    "content://media/internal/images/media"
            ));
            startActivityForResult(intent, PICK_IMAGE);
        }
    });

    delImg = findViewById(R.id.delImageButton);
    delImg.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            startImageRemove();
        }
    });
}

protected void onStart() {
    super.onStart();

    try {
        if (db.getimage(stockNumber) != null) {
            //imageView.setImageBitmap(db.getimage(stockNumber));

imageView.setImageBitmap(Bitmap.createScaledBitmap(db.getimage(stockNumber), 500, 500, false));
        }
    } catch (NullPointerException e) {
        Toast.makeText(getApplicationContext(), "Internal database error!\nset new 
image and try again...", Toast.LENGTH_LONG).show();
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (resultCode == RESULT_OK && requestCode == PICK_IMAGE) {
        Uri uri = data.getData();
        String x = getPath(uri);

        db.deleteItem(stockNumber);
        finish();

        if (db.insertimage(x, stockNumber)) {
            Toast.makeText(getApplicationContext(), "Successful", Toast.LENGTH_SHORT).show();
        } else {
            Toast.makeText(getApplicationContext(), "Not Successful", Toast.LENGTH_SHORT).show();
        }
    }
}

public String getPath(Uri uri) {
    if (uri == null) return null;
    String[] projection = {MediaStore.Images.Media.DATA};
    Cursor cursor = managedQuery(uri, projection, null, null, null);
    if (cursor != null) {
        int column_index = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.DATA);
        cursor.moveToFirst();
        return cursor.getString(column_index);
    }
    return uri.getPath();
}

```

I was thinking on a way to compress an image once its chosen from the media store on the device before adding it into the database however I'm still relatively new to programming and Android Studio, any help or suggestions is greatly appreciated as always :)