Save/load position of image

I have a little problem with saving a position for my image. I have action in my app which animate image to the certain position. I want to save this position for the image and shut down app and then when I open app I want found the image into the position when I save it. How can I do this?

Answers


Save it in a file, the first number is the x-coordinate, an the second the y-coordinate ;) The first line for x and the second for y. You will have just to parse either String to int.

EDIT

    // Saving....
    DataOutputStream dos;

    try {
        dos = new DataOutputStream(
                new BufferedOutputStream(
                        new FileOutputStream(
                                new File("myFile.txt"))));
        dos.writeInt(678); // x-coordinate
        dos.writeInt(239); // y-coordinate
        dos.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }   
    // Loading....

    int x, y;
    DataInputStream dis;

    try {
        dis = new DataInputStream(
                new BufferedInputStream(
                        new FileInputStream(
                                new File("myFile.txt"))));

        x = dis.readInt();
        y = dis.readInt();
        dis.close();

    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }   

Need Your Help

What does the NIO constraint level do exactly, and how does it affect performance?

java constraints nio netty

I noticed the following output from the WebSphere (IBM) JDK when I start my server with Netty NIO code. I am using Netty 3.4.0 FINAL with IBM JDK for WebSphere 6.1.

Dismiss modalviewcontroller with a page curl

iphone curl model-view-controller

I am trying to dismiss a modalviewcontroller with a page curl. The curl works okay but I cannot seem to get the tableview under the modalviewcontroller to show up. The image of the modalviewcontrol...