Fix NullPointer bugs and DB create syntax.

Fix a number of null pointer exceptions that can occur when writing
Cards to the database, if some fields had not been set. Fix syntax for
creating SQLite tables that had missing commas.

Change-Id: Iccb51ef6de99a7bf6650952bce9cd3d1aa34ede7