Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

Okay, I still don't understand the purpose of doing that as you're not actually reporting the internal memory size of the data *or* the size that it is encoded in on the phones memory; as you don't know whether it is stored as sql , xml or whatever.

 

But if it's something you want to do then esec's answer above is as good as any other, after his code add;

 

qint64 sizeInBytes = file.size();

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 151
Registered: ‎09-28-2012
My Device: Blackberry Developer
My Carrier: Aircel

Re: how can i wirte the data into temporary file .??

not getting you properly,

 


----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

LOL, which bit?

 

The code side or why I'm not understanding why you are doing what you are doing?

 

 

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 151
Registered: ‎09-28-2012
My Device: Blackberry Developer
My Carrier: Aircel

Re: how can i wirte the data into temporary file .??

the code side...

 

and what i am doing that is possible that why i am doing,

beacause its my requirement to get the size of contacts in bytes.. 


----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

[ Edited ]

I understand requirements but sometimes a developer has to turn back to their contractor and ask why and do you know this is meaningless. If your spec is to report back the size of contacts within the physical device then that spec is unachievable at this point in time and from a strictly professional point of view you should feedback that what you are returning as the number of bytes is at best an approximation.

 

Anyway to achieve this this is the code;

 

qint64 myClass::getContactsApproxByteSize() {
    QFile file(QDir::homePath() + "/YourFile");
    if ( file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text)) {         QTextStream stream( &file );
        for (int i=0; i <= contactArray.size(); i++)              stream << contactArray.at(i);         //The String That You Want Write;         file.close();      }
     return file.size();
}

 

Obviously the array (bold, italic) used should be replaced with whatever data structure you are using to hold the contact information.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

@esam_tec you can't write to the assets folder this code will break on a real device.


esam_tec wrote:

QFile file(QDir::currentPath() + "/app/native/assets/YourFile");
if ( file.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text))
{
QTextStream stream( &file );
stream << The String That You Want Write;
file.close();
}


 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 151
Registered: ‎09-28-2012
My Device: Blackberry Developer
My Carrier: Aircel

Re: how can i wirte the data into temporary file .??

thank you very much @BBSJdev..

 

code is working fine, but one more thing the file is creating and the size of that file is excatly equal to the size of contacts.


----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

You're welcome. I don't think you are ever going to get what I'm trying to say on the accuracy side but if you're happy then I'm happy.


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: how can i wirte the data into temporary file .??

[ Edited ]

Can you set the solution to the post above the current one you have it set as as esam_tec's solution will crash the app on a real device and so therefore cannot be considered the solution.  By all means hit the like button on some of his posts to show your appreciation.

 

However anyone looking for an answer and going straight to that one will be disappointed.

 


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Developer
Posts: 105
Registered: ‎09-06-2013
My Device: Z10

Re: how can i wirte the data into temporary file .??

Size of contacts = Contacts Count = QList<Contact> variable size() ???

 

Unless they dont mean the same thing, are you trying to get the size of the contacts db? Im afraid that isnt possible, u can only get the total number of contacts