Use shared preferences as storage, fix empty cursor, improve logging