×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    S40 system property for images folder

    According to
    http://www.developer.nokia.com/Resou...roperties.html
    the system property "fileconn.dir.photos" should return me the path of the dir where the photos are stored but on it doesnt return the correct path on s40 (i've tried on FT phone via RDA and my own x3-02).

    can some one tell me the correct system property to get the correct path?

  2. #2
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: S40 system property for images folder

    Hi shaii,

    use system property fileconn.dir.photos.name that should return the path of the directory where the photos are stored.

  3. #3
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    Re: S40 system property for images folder

    That would only return the localized folder name of the photos directory as mentioned in the implementation notes in the same link i gave you above.
    fileconn.dir.photos.name - "Localized name for the photo directory, for example "Images"."
    its more to display the user the correct folder name in their own language its not to open a file connection to that.

  4. #4
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: S40 system property for images folder

    Hi shaii,

    In S40 devices you can only see localized directory names for photos. I tested following code in Asha 302 and Asha 306 devices and works fine.

    Enumeration drives = FileSystemRegistry.listRoots();
    String drive = (String) drives.nextElement();
    FileConnection fileConn = (FileConnection) Connector.open("file:///" + drive +System.getProperty("fileconn.dir.photos.name")+"image1.png", Connector.READ_WRITE);

  5. #5
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    Re: S40 system property for images folder

    if that is true then it goes against what the docs & midp2.0 specs says.

    because even on the nokia developer library it says
    "fileconn.dir.photos - The URL of the default storage directory for photos captured with the integrated camera and other images. For example, "file:///c:/My files/Images/"."

  6. #6
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: S40 system property for images folder

    I guess you misunderstood the spec or usage of the system property “fileconn.dir.photos”.

    "fileconn.dir.photos" - The URL of the default storage directory for photos captured with the integrated camera and other images. In this case it returns the non-localized directory names. For example, in emulator you can get non localized directory name as “file:///C:/predefgallery/predefphotos/”. You can’t find these directory names if you search in the real device or emulator, because photo directory names are localized directory names in device.

    "fileconn.dir.photos.name" - Localized name for the photo directory. In this case it returns localized directory names. For example, “/files/images/”. You can easily find these directories in the real device.

    Yeah, I can see that examples are bit misleading in the developer library. They are not representing exact localized or non-localized directory names, just represents format of the path.

  7. #7
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    Re: S40 system property for images folder

    I think you are wrong... i when i use the fileconn.dir.photos property name i do get a valid folder name which does contain some graphics but not of the camera/photos gallary.
    i think that this issue came to life when nokia change the camera folder to the DCIM format.

    also i've tried your way but i cannot open the folder of that images (i need know what file names are there to present them in gallaray format and in your example you gave a direct path to an image.
    when i try to open the same thing but of the folder i get securityexception access denied

  8. #8
    Nokia Developer Expert
    Join Date
    May 2012
    Location
    Espoo
    Posts
    224

    Re: S40 system property for images folder

    Open a connection to directory where images are located like below:
    FileConnection fileConn = (FileConnection) Connector.open("file:///" + drive +System.getProperty("fileconn.dir.photos.name", Connector.READ_WRITE);
    And then get the list of files+directories in that directory, and read each file using loop below:
    Enumeration filelist = fileConn.list();
    while (filelist.hasMoreElements()) {
    String fileName = (String) filelist.nextElement();
    }
    You need to include file connection permissions(MIDlet-Permissions) in the .JAD file to avoid "securityexception access denied".

    You can read more about file connection here

  9. #9
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    Re: S40 system property for images folder

    hi bandarap,
    i'm well aware how to use file connection im a 8 years programmer working with j2me, and when i try to use your code on the nokia sdk 2.0 emulator i get the exception i've mentioned above.
    and when i use my own code i DONT get that exception but that directory is empy.

  10. #10
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,572

    Re: S40 system property for images folder

    Hi, I am reading this thread for a while and I am pretty confused.
    Thing1: why do not you check what these properties contain? There are too much "for example" and "you can get" in this thread, it would be much more specific to actually print what they are
    Thing2: check http://www.developer.nokia.com/Commu...on-memory-card if it gives some additional ideas, like the feeling that prefixing fileconn.dir.photos.name with a mere "file:///" may not be enough
    (Rationale: I have no Series 40 / Java ME SDK-s installed, so I can not check them in a few seconds)

  11. #11
    Registered User
    Join Date
    Dec 2004
    Posts
    370

    Re: S40 system property for images folder

    Hey wizard,

    The System.getProperty("fileconn.dir.photos.name") on the sdk 2.0 emulator returns the string "/files/images"
    with no drive letter even so you are correct you cant just append "file:///" to it.
    I feel like nokia made an error in their implementation and the system property "fileconn.dir.photos" should have return full path to the current phots gallery folder (doesnt matter if its on SD, internal memory based on the user selected option in the camera app)

    on a side note the i've tested the system.property("fileconn.dir.photos") on symbian^3 return c:/data/images and on s40 x3-02 return "C:/predefgallery/predefphotos/" as bandarp wrote.
    i just want to know what is the current user folder of the photos gallery whether its on SD or internal mem.

  12. #12
    Nokia Developer Expert
    Join Date
    Aug 2011
    Posts
    555

    Re: S40 system property for images folder

    i just want to know what is the current user folder of the photos gallery whether its on SD or internal mem.
    My impression is that the confusion, comes from the fact that each platform (Series 40/Symbian) has a different absolute path to the Gallery directory. That's why one can use the System property "fileconn.dir.photo" in order to use the same code for cross platform development.

    I feel like nokia made an error in their implementation and the system property "fileconn.dir.photos" should have return full path to the current phots gallery folder
    The fileconn.dir.photos returns the URL locator that one needs in order to open a file connection to the root of the gallery directory. In the case of SDK 2.0, this evaluates to

    file:///C:/predefgallery/predefphotos/

    You could easy copy an image, say "sample.jpg" to the following path:
    C:\Nokia\Devices\Nokia_SDK_2_0_Java\bin\storage\2000\C\predefgallery\predefphotos\

    then launch the SDK 2.0 emulator. You should be able to see the picture you just copied, by selecting the gallery app from the emulator.

    Alternatively, if you need to read/open a picture stored in the gallery with a Java application, you could again copy the file sample.jpg to the same directory (C:\Nokia\Devices\Nokia_SDK_2_0_Java\bin\storage\2000\C\predefgallery\predefphotos\) and use this code:

    Main MIDlet
    Code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Image;
    import javax.microedition.lcdui.ImageItem;
    
    
    public class ReadMIDlet 
    	extends MIDlet implements CommandListener {
    	
        private Form form;
    
        private Command exitCommand;
        private Command openImage;
        
        public void startApp() {
            form = new Form("ReadMIDlet");
            exitCommand = new Command("Exit", Command.EXIT, 1);
            openImage = new Command("Open", Command.OK, 2);
            form.addCommand(exitCommand);
            form.addCommand(openImage);
            form.setCommandListener(this);
            Display.getDisplay(this).setCurrent(form);
            
     
            Display.getDisplay(this).setCurrent(form);
        }
     
        public void pauseApp() {
        
        }
     
        public void destroyApp(boolean unconditional) {
        	
        }
     
        public void commandAction(Command c, Displayable d) {
        	if (c == openImage) {
        		DirectCanvas canvas = new DirectCanvas();
        		canvas.openImage();
        		Display.getDisplay(this).setCurrent(canvas);    		
            }
        }
    
    }
    Supportive Canvas class

    Code:
    import java.io.InputStream;
    
    import javax.microedition.io.Connector;
    import javax.microedition.io.file.FileConnection;
    import javax.microedition.lcdui.Canvas;
    import javax.microedition.lcdui.Graphics;
    import javax.microedition.lcdui.Image;
    
    import com.sun.lwuit.EncodedImage;
    
    public class DirectCanvas extends Canvas{
    
    	String path;
    	Image img;
    	
    	DirectCanvas() {
    		path = System.getProperty("fileconn.dir.photos") + "sample.jpg"; 
    		System.out.println(path);
    	}	
    	protected void paint(Graphics g) {
    		g.drawImage(img, 0, 0, Graphics.TOP | Graphics.LEFT);
    	}
    	
    	public void openImage() {
        	
        	try {
    
         			
                FileConnection fc = (FileConnection)Connector.open(path, Connector.READ);
                if(!fc.exists()) {
                    System.out.println("File not found!\n");
                }
                else 
                {
                    int size = (int)fc.fileSize();
                    InputStream is = fc.openInputStream();
                    
                    byte bytes[] = new byte[size];
                    is.read(bytes, 0, size);
                    
                    
                    img = Image.createImage(bytes, 0, size);
                    repaint();
                                     
                    is.close();
                    fc.close();
                    System.out.println("Done");
                }
            } catch (Exception e) {
                System.out.println("Exception: "+e.getMessage() + "\n");
            } 
    	}
    
    }

Similar Threads

  1. Replies: 3
    Last Post: 2010-08-05, 18:50
  2. system property
    By ingsaurabh in forum Mobile Java General
    Replies: 2
    Last Post: 2009-11-17, 04:42
  3. Determine OS family from a system property? Like S60 or S40?
    By kartik_vad in forum Mobile Java General
    Replies: 3
    Last Post: 2009-05-21, 07:55
  4. How to set emulater property so that it will display transparent images transparant
    By vinay3dec in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2004-09-08, 09:41

Posting Permissions

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