×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    22

    Question Read local files associated with the application

    Can I read the contents of text files associated with the application?

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Read local files associated with the application

    Hi Mariannu,

    what you mean by text files "associated" with your app? Maybe you text mean files packed within your widget?

    Pit

  3. #3
    Registered User
    Join Date
    Jul 2009
    Posts
    22

    Re: Read local files associated with the application

    Yes, text files packed with the widget

    I am trying to create an application somewhat similar to a dictionary... the app will pull the words list from a file, and then, according to the user selection, the "result" is also pulled again from the word's text file

    In PyS60, I could just zip all the text files (to reduce installation time, since they are about 4000 files), and read them... Can a widget open a zip file? and can it pull the text from a text file?

  4. #4
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Read local files associated with the application

    Hi Mariannu,

    afaik there are no methods to directly read content of files packed within the widget itself.

    Anyway, you could easily solve it by using a JavaScript file (or more of them), listing all your dictionary entries in JSON format:
    Code:
    var dictionary = {
      'Key 1': 'Definition of Key 1.......',
      'Key 2': 'Definition of Key 2.......'
    };
    This would also speed up a lot the search of keys, since you could get them in a simple line of code:
    Code:
    var key1Definition = dictionary['Key 1'];
    You could also store entries in different data formats, as plain arrays or more complex objects.

    Hope it helps,
    Pit

  5. #5
    Registered User
    Join Date
    Jul 2009
    Posts
    22

    Question Re: Read local files associated with the application

    That's a good idea, but, what if there are 4000 entries? Wouldn't that increase the memory required for the application to an extent that may be unusable in mobile devices?!

  6. #6
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Read local files associated with the application

    Yes, it could require more memory than the available one. Best thing here would be to test on real devices, and see how the whole behaves.

    A possible way to overcome this problem would be to split up the whole dictionary in more JS files and objects, and to dynamically load them on-the-fly when needed (and disposing them when needed no more). This article contains some useful related code (talks about external JS libraries, but should work with internal JS files as well):

    http://wiki.forum.nokia.com/index.ph...ies_at_Runtime

    Pit

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Manaus, Brazil
    Posts
    109

    Re: Read local files associated with the application

    Hi,


    It's not the perfect solution, but it is the answer of your question. You can use ajax. You can use jQuery:

    jQuery.ajax({

    url: "database.txt",
    type: "GET",
    dataType: "text",
    success: function(data) {
    alert(data);
    },
    error: function(data) {

    },
    complete: function() {

    }

    });
    Javier Zambrano Ferreira

  8. #8
    Nokia Developer Champion
    Join Date
    Nov 2007
    Location
    Rome, Italy
    Posts
    2,405

    Re: Read local files associated with the application

    Hi jzferreira,

    never tried local Ajax calls.. great to know that these do work! Thanks for sharing it

    Pit

Similar Threads

  1. Replies: 4
    Last Post: 2010-03-31, 17:55
  2. iPhone Blogger Blog Creation Application
    By semaphore10 in forum News and Announcements
    Replies: 4
    Last Post: 2009-10-06, 08:49
  3. Replies: 4
    Last Post: 2009-08-19, 10:04
  4. Looking for local partners to market a new application
    By Clocklabs Ltd in forum Mobile Java General
    Replies: 0
    Last Post: 2004-07-26, 21:11

Posting Permissions

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