Hi.
My app worked totally fine on iOS4, but crashes frequently on iOS5.
I have been finding out what is wrong and I just found the clue.
It seems there is a bug to read data from Sqlite on iOS5.
The old data that made on lower iOS than iOS5 can read properly in both Unity and Cocoa.
When I make new data into database and try to get the record in Unity, unity sends an exception and an App get crashed.
This is the code
public UserInfo getUserInfo(int key)
{
UserInfo userInfo = new UserInfo();
string query = "SELECT * FROM user_info WHERE id= " + key;
IDbCommand dbcmd = dbcon.CreateCommand();
dbcmd.CommandText = query;
dbcmd.Prepare();
IDataReader reader = dbcmd.ExecuteReader(); // <- crash here
byte[] imageByte = null;
long imageSize = 0;
while(reader.Read()) {
userInfo.id = reader.GetInt32(0);
imageSize = reader.GetBytes(1, 0, null, 0, 0);
if(imageSize > 0)
{
imageByte = new byte[imageSize];
reader.GetBytes(1, 0, imageByte, 0, (int)imageSize);
userInfo.photo = new Texture2D(FACE_FRAME_WIDTH, FACE_FRAME_HEIGHT);
userInfo.photo.LoadImage(imageByte);
}
userInfo.sex = reader.GetInt32(2);
userInfo.type = reader.GetInt32(3);
}
reader.Close();
reader = null;
dbcmd.Dispose();
dbcmd = null;
return userInfo;
}
In addition, The most strange thing is that the new data can be read In Cocoa without any problem.
HUserInfo *info = [aquaDB getHUserInfo:personID];
NSLog(@" id = %d", info.iD);
NSLog(@" type = %d", info.type); // No matter to read.
Does anybody have problem to handle Sqlite on iOS5 like me?