Correctly read the to-device stream ID on startup using SQLite.