how to write data into IGallery_db | developer.brewmp.com how to write data into IGallery_db | developer.brewmp.com

Developer

how to write data into IGallery_db

Forums:

HI, i want to fetch value/data from IGallery_DB. By default there is nothing inside the IGallery_DB. Can i write any file to IGallery_DB using IFileMGR? if so how? Using IFileMGR iam able to write a file to shared folder , but no entry is made in IGallery_DB corresponding to that. How do i do that?

Thanks in advance

Hi annu,
I assume you want to create a file, add an entry to Gallery DB, and then modify/query that entry. If not, please reply back to clarify your question.
Say you've created a file using IFileMgr called "fs:/shared/testfile.mp3".
To add that file to Gallery, you need to sync that file to Gallery:
nRetVal = IGallery_Sync(piGallery, "fs:/shared/testfile.mp3", YourCBFunction, YourPrivateData);
Note that Sync could be asynchronous, so you need to provide a callback function that Gallery can call after it's done adding the entry to the DB.
To query/change the data after that, you can use IGallery_Query and IGallery_Update.
All of the IGallery API are documented in AEEGallery.h, please refer to that file or reply to this thread if you need more clarification.
Thanks,
Edward

Hi annu,
I assume you want to create a file, add an entry to Gallery DB, and then modify/query that entry. If not, please reply back to clarify your question.
Say you've created a file using IFileMgr called "fs:/shared/testfile.mp3".
To add that file to Gallery, you need to sync that file to Gallery:
nRetVal = IGallery_Sync(piGallery, "fs:/shared/testfile.mp3", YourCBFunction, YourPrivateData);
Note that Sync could be asynchronous, so you need to provide a callback function that Gallery can call after it's done adding the entry to the DB.
To query/change the data after that, you can use IGallery_Query and IGallery_Update.
All of the IGallery API are documented in AEEGallery.h, please refer to that file or reply to this thread if you need more clarification.
Thanks,
Edward

Hi Edward,
Thank You so much for your reply. I have tried sync and mount the data.
Do i have to Mount the folders before sync. Pls have a look at my code . I am inserting mp3 files to the shared folders. When i tried with image files i was able to retrieve the data.
.......................................
.......................................
IGallery_MountDirs(pMe->myGallery, "fs:/shared/");
IGallery_Sync(pMe->myGallery,"fs:/shared/",IGallerySample_GallerySyncNotifyCB,pMe);
IGallery_Query(pMe->myGallery,L"*" , NULL, NULL, NULL, NULL,NULL, NULL,&pMe->mySQLStmt);
ISQLSTMT_Step(pMe->mySQLStmt);
pColName = ISQLSTMT_ColumnName(pMe->mySQLStmt,1);
nSize = ISQLSTMT_ColumnSize(pMe->mySQLStmt,1); //Returns 0 bytes
err = ISQLSTMT_GetColumnText(pMe->mySQLStmt,1, &pColText);
//Returns error code 28693
.........................................
...........................................
I got data when i put image files in the shared folder.
But am getting the same old data when i changed the files from shared folder.
Could you pls tell me where i am wrong....???

Hi Edward,
Thank You so much for your reply. I have tried sync and mount the data.
Do i have to Mount the folders before sync. Pls have a look at my code . I am inserting mp3 files to the shared folders. When i tried with image files i was able to retrieve the data.
.......................................
.......................................
IGallery_MountDirs(pMe->myGallery, "fs:/shared/");
IGallery_Sync(pMe->myGallery,"fs:/shared/",IGallerySample_GallerySyncNotifyCB,pMe);
IGallery_Query(pMe->myGallery,L"*" , NULL, NULL, NULL, NULL,NULL, NULL,&pMe->mySQLStmt);
ISQLSTMT_Step(pMe->mySQLStmt);
pColName = ISQLSTMT_ColumnName(pMe->mySQLStmt,1);
nSize = ISQLSTMT_ColumnSize(pMe->mySQLStmt,1); //Returns 0 bytes
err = ISQLSTMT_GetColumnText(pMe->mySQLStmt,1, &pColText);
//Returns error code 28693
.........................................
...........................................
I got data when i put image files in the shared folder.
But am getting the same old data when i changed the files from shared folder.
Could you pls tell me where i am wrong....???

Hi annu,
Yes, it is recommended to call Mount before calling any other APIs like Sync, Query, etc.
Like I mentioned before, Sync is asynchronous, so please call Query, Step, etc. in your cb function (IGallerySample_GallerySyncNotifyCB).
I'm guessing this is the problem since mp3 data requires more metadata parsing than images, so while you only have images sync might have completed synchronously (but please not that this is not guaranteed!, to be safe you always need to query after sync is done, in the CB function).
Some clarification also:
When you query all columns (using *), the column order is not guaranteed, so you need to check the col type (ISQLSTMT_ColumnDataType) before calling appropriate Get functions.
Let me know if it's still not working.
Thanks,
Edward

Hi annu,
Yes, it is recommended to call Mount before calling any other APIs like Sync, Query, etc.
Like I mentioned before, Sync is asynchronous, so please call Query, Step, etc. in your cb function (IGallerySample_GallerySyncNotifyCB).
I'm guessing this is the problem since mp3 data requires more metadata parsing than images, so while you only have images sync might have completed synchronously (but please not that this is not guaranteed!, to be safe you always need to query after sync is done, in the CB function).
Some clarification also:
When you query all columns (using *), the column order is not guaranteed, so you need to check the col type (ISQLSTMT_ColumnDataType) before calling appropriate Get functions.
Let me know if it's still not working.
Thanks,
Edward

Hi Edward
Thank you so much
I am able to retrieve the correct column name when i put IGallery_Query after sync() . But when it comes to column size its retrurns 0 ;
I have copied the query part in to the SyncNotifyCB function. But the control is not at all going to the SyncNotifyCB function.
Here is my SyncNotifyCB function. Plsss Have a look
void IGallerySample_GallerySyncNotifyCB(void *pCBData, AEEGallerySyncStatus *pSyncStatus)
{
IGallerySample *pMe = (IGallerySample*)pCBData;
//if (AEEGALLERY_SYNC_STATE_COMPLETE == pSyncStatus->nSyncState)
//{
err = IGallery_Query(pMe->myGallery,L"*" , NULL, NULL, NULL, NULL,NULL, NULL,&pMe->mySQLStmt);
ISQLSTMT_Step(pMe->mySQLStmt);
err=ISQLSTMT_ColumnCount(pMe->mySQLStmt);
name = ISQLSTMT_ColumnName(pMe->mySQLStmt,1);
err = ISQLSTMT_ColumnSize(pMe->mySQLStmt,1);
err=ISQLSTMT_GetColumnText(pMe->mySQLStmt,1, &diname);
//}

Hi Edward
Thank you so much
I am able to retrieve the correct column name when i put IGallery_Query after sync() . But when it comes to column size its retrurns 0 ;
I have copied the query part in to the SyncNotifyCB function. But the control is not at all going to the SyncNotifyCB function.
Here is my SyncNotifyCB function. Plsss Have a look
void IGallerySample_GallerySyncNotifyCB(void *pCBData, AEEGallerySyncStatus *pSyncStatus)
{
IGallerySample *pMe = (IGallerySample*)pCBData;
//if (AEEGALLERY_SYNC_STATE_COMPLETE == pSyncStatus->nSyncState)
//{
err = IGallery_Query(pMe->myGallery,L"*" , NULL, NULL, NULL, NULL,NULL, NULL,&pMe->mySQLStmt);
ISQLSTMT_Step(pMe->mySQLStmt);
err=ISQLSTMT_ColumnCount(pMe->mySQLStmt);
name = ISQLSTMT_ColumnName(pMe->mySQLStmt,1);
err = ISQLSTMT_ColumnSize(pMe->mySQLStmt,1);
err=ISQLSTMT_GetColumnText(pMe->mySQLStmt,1, &diname);
//}

Hi annu,
Please remove the Query call (and any related ISQLStmt calls) after Sync in the same function, you should only do these in the CB function. Most likely the column size returns 0 because there is no data yet in the DB. You can also check the return value of the Sync call, if it's pending, that means sync is asynchronous.
Are you saying the CB function isn't getting called? Most likely this indicates the Sync call failed. Can you check the return value of the Sync call?

Hi annu,
Please remove the Query call (and any related ISQLStmt calls) after Sync in the same function, you should only do these in the CB function. Most likely the column size returns 0 because there is no data yet in the DB. You can also check the return value of the Sync call, if it's pending, that means sync is asynchronous.
Are you saying the CB function isn't getting called? Most likely this indicates the Sync call failed. Can you check the return value of the Sync call?

Hi Edward
Sync call returns 0.
err2 = IGallery_Sync(pMe->myGallery,"fs:/shared/",IGallerySample_GallerySyncNotifyCB,pMe); //err2 =0
In "fs:/shared/" folder i have copied 5 mp3 files.
Still the CB function is not getting called....
Thank You

Hi Edward
Sync call returns 0.
err2 = IGallery_Sync(pMe->myGallery,"fs:/shared/",IGallerySample_GallerySyncNotifyCB,pMe); //err2 =0
In "fs:/shared/" folder i have copied 5 mp3 files.
Still the CB function is not getting called....
Thank You

Can you send me your gallery.db file under fs:/shared?
My email is if you can't attach it here.

Can you send me your gallery.db file under fs:/shared?
My email is if you can't attach it here.

The issue has been resolved.
The cause of the problem is a database lock preventing the Sync from completing.

The issue has been resolved.
The cause of the problem is a database lock preventing the Sync from completing.