×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Deleting file from memory card

    Hello,
    I am developing application which needs to delete oldest file in memory card.
    If any one is having related information plz e-mail me on rbangar30@gmail.com
    Thanx in advance.

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,553

    Re: Deleting file from memory card

    JSR-75 FileConnection APIs has all you need to find, create, modify and delete files. Examples in the wiki: http://www.developer.nokia.com/Commu.../Data_Articles

    Details in the SDK docs.

  3. #3
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Deleting file from memory card

    Quote Originally Posted by rbangar30 View Post
    Hello,
    I am developing application which needs to delete oldest file in memory card.
    If any one is having related information plz e-mail me on rbangar30@gmail.com
    Thanx in advance.
    Using FlieConnection API - FileConnection.list();Gets a list of all visible files and directories contained in a directory. The directory is the connection's target as specified in Connector.open().
    Now you can check the lastModified(); for each file and to identify the oldest filename.

    Once you get it - use FileConnection.delete() for this file and you are done.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  4. #4
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Re: Deleting file from memory card

    thanks Amitabh , but lastModified() Returns the time that the file denoted by the URL specified in the Connector.open() method was last modified.So to get oldest file I need to compare time of modification of all files in directory which is not at all feasible.
    Any other solution??

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: Deleting file from memory card

    Quote Originally Posted by rbangar30 View Post
    thanks Amitabh , but lastModified() Returns the time that the file denoted by the URL specified in the Connector.open() method was last modified.So to get oldest file I need to compare time of modification of all files in directory which is not at all feasible.
    Any other solution??
    Solution:
    Assume that the first file name is the oldest file, store its path and last modified in two variables, Now re-curse through the complete directory once - if you find any file with lastModified() long value is smaller then the one you assumed & stored (first one) as the oldest - store its path and last modified as the oldest... and continue the loop.

    At the end of the loop you will the oldest file - delete it.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Registered User
    Join Date
    Oct 2011
    Posts
    10

    Re: Deleting file from memory card

    Quote Originally Posted by im2amit View Post
    Solution:
    Assume that the first file name is the oldest file, store its path and last modified in two variables, Now re-curse through the complete directory once - if you find any file with lastModified() long value is smaller then the one you assumed & stored (first one) as the oldest - store its path and last modified as the oldest... and continue the loop.

    At the end of the loop you will the oldest file - delete it.
    Ya its true but it will take lot of time if memory card has thousands of files.Is there any fastest solution??
    Thanx!!!

Similar Threads

  1. Cant read file on memory card
    By david.morgan in forum Symbian
    Replies: 4
    Last Post: 2011-01-07, 09:31
  2. direct copy a file from resource(jar file) to memory card
    By universoft in forum Mobile Java General
    Replies: 1
    Last Post: 2010-01-10, 13:39
  3. Reading text file stored in phone memory/memory card
    By devdattac in forum Mobile Java General
    Replies: 6
    Last Post: 2008-09-19, 19:30
  4. File Run Not working On Memory Card
    By kdurga in forum Symbian
    Replies: 11
    Last Post: 2008-07-16, 09:24
  5. Memory card file access
    By martin.wainamoinen in forum Mobile Java General
    Replies: 0
    Last Post: 2008-03-12, 22:28

Posting Permissions

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