Question: sorry, I need some help finding the right regular expression for this.
Basically I want to recognize via regex if the following format is in a string:

artist - title (something)

examples:

```
"ellie goulding - good gracious (the chainsmokers remix)"
"the xx - you got the love (florence and the machine cover)"
"neneh cherry - everything (loco dice remix)"
"my chemical romance - famous last words (video)"

```

I have been trying but haven't been able to find the right regular expression.

```
regex = "[A-Za-z0-9\s]+[\-]{1}[A-Za-z0-9\s]+[\(]{1}[\s]*[A-Za-z0-9\s]*[\)]{1}"

```

help please!

Answer: 
The simplest technique you can follow is to store your Image path in the database table as a String and then you can get it back whenever you need that image and decode it using `BitmapFactory.decodeFile`. Storing Base64String is fine but the string will have too large so, if you will see the path of image it is comparatively a shorter string

**For Example:**

* define another parameter in your `createRecipe()` method named `String imagePath` like:

`public void createRecipe(String name,String type, String ingred,String imgPath){}`

* When you make a call to this function you will pass the image path what ever you have like:

`createRecipe(name,type,ingred,path_of_image)`

To get ImagePath you can do something like that:

```
String destination = new File(Environment.getExternalStorageDirectory(), name_of_your_image+ ".jpg");
FileInputStream in = new FileInputStream(destination);
String photoPath = destination.getAbsolutePath();

```

* Finally when you call your `fetchRecipesByName()` or `fetchAllRecipes()` method the `Cursor` will now have your path stored against each entry you can get this path as a String and pass it to the below function you will get Bitmap in return.

> 
> 
> ```
> private Bitmap getBitmapFromPath(String path)
> {     
>     BitmapFactory.Options btmapOptions = new BitmapFactory.Options();
> 
>     btmapOptions.inSampleSize = 2;
> 
>     Bitmap bm = BitmapFactory.decodeFile(path, btmapOptions);
> 
>     return bm;
> }
> 
> ```
> 
> 

**Note:** You should also take care if you are storing path of image and it could be deleted from gallery so in return you cannot have any bitmap against this path so you should manage if image dosen't exist then use an alternative image.
This is a method to store your bitmap image into database, you need to assign a type of column as Blob for image in database table

```
protected long saveBitmap(SQLiteDatabase database, Bitmap bmp) {
        Log.d("ImageDatabase", "::  Method Called");
        int bytes = bmp.getByteCount();
        ByteBuffer buffer = ByteBuffer.allocate(bytes);
        bmp.copyPixelsToBuffer(buffer);
        byte[] array = buffer.array();

        Log.d("ImageDatabase", "::  ByteArray Created");
        ContentValues cv = new ContentValues();
        cv.put("img", bytes);
        Log.d("ImageDatabase", "::  Before Insert");
        long rs = database.insert("images", null, cv);
        Log.d("ImageDatabase", "::  After Insert");
        return rs;
    }

```