Reputation: 31
I am trying to pre-populate a room database with some data using DB Browser for sqlite.
I have a table defined with (name: String, score:Int, image:Int). That image field stores an image from drawable folder so the example for an insert would be :
INSERT INTO player (name,score,image) VALUES ("Mike", 31, R.drawable.mike)
Since the table field is Int, DB Browser wont let me store R.drawable.mike which is the image location in android studio as it expects a number. Error :
Execution finished with errors.
Result: no such column: R.drawable.mike
At line 1:
INSERT INTO player (name,score,image) VALUES ("Mike", 31, R.drawable.mike)
I have tried using a BLOB type for image but it returns the same error as above.
Any ideas on how I can do this ? If I define image to be a string how can I make android studio read "R.drawable.mike" as id location later in the code?
Or how can I prepopulate a room database with such data in some other way ?
Upvotes: 0
Views: 234