×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Problem with writing files on device

    I successfully save text to external file with this code, but it works only on Nokia QT SDK emulator. On device I receive just empty video.ram file.

    Code:
        QString video; // video url string
        QTextCodec *codec = QTextCodec::codecForName("UTF-8");
        QByteArray data = codec->fromUnicode(video);
        
        const char* videoUrl = data.constData();
    
        QFile *file = new QFile("e://video.ram");
        if (file->open(QIODevice::WriteOnly)) {
        QTextStream out(file);
    
        out << videoUrl;
        file->close();
    Note:I set the permission writeUserData in .pro file

    Please advice!


    Thanks

  2. #2
    Super Contributor
    Join Date
    Jul 2008
    Posts
    2,020

    Re: Problem with writing files on device

    Does the device have a volume e, not f?

    Check in file manager.
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  3. #3
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Re: Problem with writing files on device

    Yes mass storage is e volume, and what is strange when I put 'manualy' for example:

    out << "rtsp://v3.cache7.c.youtube.com/CjYLENy73wIaLQnHdoOcHgUFfBMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYLbi-pqEivrSTQw=/0/0/0/video.3gp";

    everything is ok.

    I'm puzzled by this.

    I use qt4.6 and E7 Nokia device.

  4. #4
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem with writing files on device

    1. make sure codec->fromUnicode(video); returning something by checking size of QByteArray data and
    2. try out << QString(data);

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Re: Problem with writing files on device

    Yes I checked just getting empty data array on device. How to solve this?

  6. #6
    Super Contributor
    Join Date
    Mar 2004
    Location
    Singapore
    Posts
    9,968

    Re: Problem with writing files on device

    Quote Originally Posted by immicro View Post
    Yes I checked just getting empty data array on device. How to solve this?
    so the problem is not in writing on the device then QTextCodec *codec = QTextCodec::codecForName("UTF-8");


    i suggest you create another ticket for this.

  7. #7
    Super Contributor
    Join Date
    Mar 2009
    Posts
    1,024

    Re: Problem with writing files on device

    Hi immicro,
    According to your code QString video is empty... is that the cause which lead you to have an empty file?

    Moreover, I've seen you are playing with codecs instead of using QString methods.
    What about using something like this??

    out << QString::fromUtf8(charsArrayBuffer);

  8. #8
    Registered User
    Join Date
    Mar 2011
    Posts
    13

    Re: Problem with writing files on device

    Yes you are right, I found error elsewhere in the code, is not related to writing to device. Sorry...

Similar Threads

  1. Writing to files in the device
    By ratnadeep_joshi in forum Symbian Tools & SDKs
    Replies: 6
    Last Post: 2010-02-16, 11:17
  2. Problems with writing 2 text files
    By nadym89 in forum Symbian
    Replies: 5
    Last Post: 2008-06-07, 13:27
  3. problem ith reading & writing text-files
    By szallah in forum Symbian
    Replies: 2
    Last Post: 2008-05-26, 00:33
  4. problem writing files
    By glamalil in forum Mobile Java General
    Replies: 13
    Last Post: 2007-06-04, 09:40
  5. Writing Files on Device from MIDP
    By terajiv in forum Mobile Java General
    Replies: 2
    Last Post: 2005-05-12, 13:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×