Gary Milne Active Member Licensed User Longtime User Sep 12, 2014 #1 When writing a MAP object to SQL it gets converted to a ByteArray. Is there an easy way to convert the ByteArray back into the original MAP object? I know I could parse it and rebuild it that way but there has to be some existing method for doing that?
When writing a MAP object to SQL it gets converted to a ByteArray. Is there an easy way to convert the ByteArray back into the original MAP object? I know I could parse it and rebuild it that way but there has to be some existing method for doing that?
LucaMs Expert Licensed User Longtime User Sep 12, 2014 #2 Do you mean objects of type Map? If so, I imagine that, if a solution exists, it is by magicians. Why complicate things? Save the data from the Map in the DB. Upvote 0
Do you mean objects of type Map? If so, I imagine that, if a solution exists, it is by magicians. Why complicate things? Save the data from the Map in the DB.
Gary Milne Active Member Licensed User Longtime User Sep 12, 2014 #3 Yes, objects of type Map. If a solution exists then it will result in simpler code as I won't have to explicity read and write to the 15 columns that would be needed in lieu. Ican also change the contents of the Map and not have to adjust the code. Upvote 0
Yes, objects of type Map. If a solution exists then it will result in simpler code as I won't have to explicity read and write to the 15 columns that would be needed in lieu. Ican also change the contents of the Map and not have to adjust the code.
Jeffrey Cameron Well-Known Member Licensed User Longtime User Sep 12, 2014 #4 Is the SQL just to store the map object? If so, see File.WriteMap. If you are storing other things as well then you are probably better off making a class that mimics your map and handles the save/load to the SQL internally. Upvote 0
Is the SQL just to store the map object? If so, see File.WriteMap. If you are storing other things as well then you are probably better off making a class that mimics your map and handles the save/load to the SQL internally.
sirjo66 Well-Known Member Licensed User Longtime User Sep 12, 2014 #5 I'm sorry, I don't know enough about Map and SQL, but a solution may be to transform the Map object to a string by JSONGenerator, and write this string into SQL database. Then you can read this string from database, and convert to Map object with JSONParser. Help here: http://www.b4x.com/android/forum/threads/android-json-tutorial.6923/#content Only a few lines for to transform Map to String and String to Map Sergio Upvote 0
I'm sorry, I don't know enough about Map and SQL, but a solution may be to transform the Map object to a string by JSONGenerator, and write this string into SQL database. Then you can read this string from database, and convert to Map object with JSONParser. Help here: http://www.b4x.com/android/forum/threads/android-json-tutorial.6923/#content Only a few lines for to transform Map to String and String to Map Sergio
LucaMs Expert Licensed User Longtime User Sep 13, 2014 #6 Since Maps and DBs can contain any type of data, I think that the best solution should be, as Jeffrey suggested, use classes. In this way, in addition to be able to use executable code (eg for validation) will be possible to save bitmaps in the DB. Gary could rightly argue that he does not want to manage 15 fields directly, let alone create an entire class. Us (at least one of us ) should develop a tool for the generation of this type of classes once and for all. Upvote 0
Since Maps and DBs can contain any type of data, I think that the best solution should be, as Jeffrey suggested, use classes. In this way, in addition to be able to use executable code (eg for validation) will be possible to save bitmaps in the DB. Gary could rightly argue that he does not want to manage 15 fields directly, let alone create an entire class. Us (at least one of us ) should develop a tool for the generation of this type of classes once and for all.
Erel B4X founder Staff member Licensed User Longtime User Sep 14, 2014 #7 Use KeyValueStore class. Upvote 0