×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    Post error message write in my mobile

    Hi all
    I write algorithm to write some think using j2me code. When I run this algorithm in PC(emulator) I succeed to write but when I applied in my mobile nokia 6210 navigator I get error message "exception Access denied"
    please tell me why and how can I solve this problem

    please replay me
    Regards

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: error message write in my mobile

    We'll need more information to help you.

    1. Is that the exact message? Are there any more details? (Is there a "details" option you can select?)

    2. When does this message appear?
    a. When you install the application?
    b. When the application starts?
    c. In the middle of running the application?

    3. If the message appears while running the app, do you know what it is trying to access? Are you access files, for example?

    Graham.

  3. #3
    Registered User
    Join Date
    Dec 2008
    Location
    Cochin, Kerala, India
    Posts
    84

    Re: error message write in my mobile

    Please specify about the error condition. I think you might got the while writing a file some restricted location.
    Post the location where u want to write the file.

    Vineeth K

  4. #4
    Registered User
    Join Date
    Feb 2010
    Posts
    12

    Re: error message write in my mobile

    hello
    I write an example to write some thing as this code
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package hello;

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.sensor.Data;

    public class HelloMIDlet extends MIDlet implements CommandListener{

    private Form form1;
    private Command Ok;
    private Display display;
    private String fileroot = "file:///c:/data/datas/";
    //public String fileroot="file://localhost/root1/"; // for computer memory
    TextBox t;
    public void startApp() {
    // form1 = new Form("");
    Ok = new Command("Ok", Command.OK, 1);
    t = new TextBox("Hello", "Hello, World!", 256, 0);

    t.addCommand(Ok);
    t.setCommandListener(this);

    display = Display.getDisplay(this);
    display.setCurrent(t);
    //form1.setCommandListener((CommandListener) this);

    //form1.append((Item)t);
    //
    //display.setCurrent(form1);
    }

    public void commandAction(Command c, Displayable d) {
    if (c == Ok) {

    boolean xx = this.writeFile();

    }
    }
    //this.notifyDestroyed();
    //}

    public void destroyApp(boolean bool) {
    }

    protected void pauseApp() {
    throw new UnsupportedOperationException("Not supported yet.");
    }

    private boolean writeFile() {

    String data = "hello world!!";
    javax.microedition.io.Connection c = null;
    java.io.OutputStream os = null;
    try {
    String fileN = fileroot + "test.txt";

    c = javax.microedition.io.Connector.open(fileN, javax.microedition.io.Connector.READ_WRITE);
    javax.microedition.io.file.FileConnection fc = (javax.microedition.io.file.FileConnection) c;
    if (!fc.exists()) {
    fc.create();
    } else {
    fc.truncate(0);
    }
    os = fc.openOutputStream();

    byte[] ss = data.getBytes();
    os.write(ss);
    //os.write(data);
    os.flush();

    t.setString("done file created ");
    return true;
    } catch (Exception e) {
    t.setString("exception "+e.getMessage());
    return false;
    } finally {
    try {
    if (os != null) {
    os.close();
    }

    if (c != null) {
    c.close();
    }
    } catch (Exception ex) {
    // ex.printStackTrace();
    return false;
    }

    }


    }



    }
    when I press run in the emulator, I can write successfully but when I apply this code in my mobile nokia 6210 navigator, I do the following steps : I restore the file in menu-->office-->file mgr. -->phone memory I create new folder named datas--> I put the .jar dist file in datas folder .
    To run this file I press install (yes) -->(security warning)--> continue--> continue--> start --> I get this message ( Hello, World) when I press ok for execute the write I get this message 'exception Access denied' this is a real message

    Regards

  5. #5
    Registered User
    Join Date
    Mar 2006
    Posts
    32

    Re: error message write in my mobile

    Hi,

    As it appears form the code you are accessing the fileSystem and writing error on a log files. On all phones permissions related with file connection operations vaary. Like on some phone using an unsigned application you can not create new directory and files , You can only edit the existing ones.
    Error mentioned by you is related with access permissions only. So make sure that
    - You have all necessary fileconnection permissions added in JAD.
    - Dirctory in which you are writing the Log file indeed exists on the phone.
    - You can also try signing the application using any third party certificate and then check.

    Also you can make use of PDAPDemo available in default SUN WTKs to check about the accessible folders, regarding rights for creating folders and files etc.

    Regards,
    Aditya Kumar Binju

  6. #6
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: error message write in my mobile

    Quote Originally Posted by elkourd View Post
    private String fileroot = "file:///c:/data/datas/";
    This is your problem. You are not permitted access to this folder.

    Read this example. Note that it gets the folder by reading the system property "fileconn.dir.photos". You should only use folders from these properties.

    Graham.

Similar Threads

  1. How to read and write to the Mifare 4K in Nokia 6131 NFC Mobile
    By suresh_jr in forum Near Field Communication
    Replies: 1
    Last Post: 2008-06-13, 11:42
  2. write code for pc and mobile connection
    By sulabh120881 in forum PC Suite API and PC Connectivity SDK
    Replies: 0
    Last Post: 2006-11-22, 05:29
  3. How to write a DB since mobile phone?
    By alexandra_bustamante in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2004-09-22, 13:42
  4. How to write a DB since mobile phone?
    By alexandra_bustamante in forum Mobile Java General
    Replies: 6
    Last Post: 2004-09-20, 14:57

Posting Permissions

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