0

I'm using SnappyDB in my app as a store for some key value pairs. I'm wrapping the DB interface with my own interface with default values in it's api. Example:

String get(String key, String defaultValue);

I noticed the only way to know if a key doesn't exist in the DB is to catch an exception and assume the reason for it was a missing key (which is a wild assumption).

Any ideas on how I could implement the default value feature in a less ugly, more accurate way that won't hide relevant exceptions?

Thanks.

Simulant
  • 19,190
  • 8
  • 63
  • 98
Moti Azu
  • 5,392
  • 1
  • 23
  • 32

1 Answers1

3

You can use:

boolean isKeyExist = snappyDB.exists("key");
spongebob
  • 8,370
  • 15
  • 50
  • 83
Nabil Hachicha
  • 216
  • 1
  • 4