0

I need to store an image (bitmap or array of bytes ) in realm database using xamarin .

when I tried to save it in a bitmap , an error appeared that realm does not support bitmap . when I tried to save it in a byte array , an error appeared that its size is too big . Also when I tried to store the path of the image , I did not get the actual path , I only get the temporary path of the image so it did not help .

is there is any solution to do this ?

maria nabil
  • 141
  • 3
  • 9
  • do you **really** need to save the image in Realm? Generally its a best practice to store large files in the file system and just reference them by path or id in the database. – Jason Jul 29 '19 at 21:40
  • Realm is a memory mapped DB and is not designed to store large blobs. As Jason stated, the preferred practice is to use a field in an RealmObject that is mapped to an image (be it a local cached file or a URL web resource or ....). Note: Also due to iOS memory management you can never have a Realm db that is larger than the largest non-fragemented memory segment available to your app, so storing blobs in it is not a good idea in the first place. – SushiHangover Jul 29 '19 at 21:43
  • but when I tried to save their only in the realm , it did not get their actual path , but it gave me the temporary path , is there any way to get the actual path ? – maria nabil Jul 29 '19 at 23:05
  • @maria,If you have larger bitmaps (images), it is better to store the images on disk, and store the path in Realm. Where you get the image? Gallery? File?, If you want to get actual path, you can take a look:https://stackoverflow.com/questions/46975574/how-to-get-actual-path-from-uri-xamarin-android/47008332 – Cherry Bu - MSFT Jul 30 '19 at 02:26

1 Answers1

0

Convert your byte array into base64 string and than store into your local database because string can store larger size of data