I face a tough problem. I want to read data from sqlite database using C #. The data field in the database is of type blob. This field contains double values ββ(also has other types of values, such as text and int) written by Java. I need to read double values ββusing C #.
I'm sorry that I made a terrible mistake in the question. I read double values ββin Java, creating a ByteBuffer initialized with a blob stream that is read from the database. And there is no ByteBuffer ByteBuffer data structure in C #, so I use the following code to get a double value from a stream of 8 bytes.
public double getDouble() { if(CURRENT_POSITION + 7 >= CURRENT_LENGTH) { return 0; } double ret = (double)(TEMP_BYTE_ARRAY[CURRENT_POSITION + 7] << 56 | TEMP_BYTE_ARRAY[CURRENT_POSITION + 6] << 48 | TEMP_BYTE_ARRAY[CURRENT_POSITION + 5] << 40 | ..... ); return ret; }
But I cannot get the correct double value from the blob field using C # using the same code. Can someone give me some tips on how to convert a binary binary style value defined by Java to a C # double value?
By the way, since the blob field compressed many other types of values, I cannot change the database structure. Thanks to everyone in advance.
source share