Results 1 to 11 of 11

Thread: Saving Values

  1. #1
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default Saving Values

    I've got a variable, lets say AGE, that the user sets while running the mobile application. How do I save the value so that when the user starts the program again, he doesnt have to re-enter his age? Is there a way to do this WITHOUT databases?
    Thanks,
    Sysem

  2. #2
    sukatoa's Avatar
    sukatoa is offline Senior Member
    Join Date
    Jan 2008
    Location
    Cebu City, Philippines
    Posts
    556
    Rep Power
    7

    Default

    mobile application...

    hhmmmhhh,
    If you can embed your application to that mobile, then it is possible to create a file through that application.... unless there was a security feature that blocks the file creation... have you ever try it?
    freedom exists in the world of ideas

  3. #3
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    Unfortunatly, im new to Java and have absolutly no idea what you mean... Do you know any tutorials that i can use for a database then? Im using netbeans with Derby db and im completely lost in using a database with java and mobility...

    Sysem

  4. #4
    Zosden's Avatar
    Zosden is offline Senior Member
    Join Date
    Apr 2008
    Posts
    384
    Rep Power
    7

    Default

    Write to a txt file.
    My IP address is 127.0.0.1

  5. #5
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    And how would i do that with a mobile application?

  6. #6
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Not too sure about Mobile applications but this is how you would write the age to a file. Probably still work the same..

    Java Code:
    import java.io.BufferedWriter;
    import java.io.FileWriter;
    import java.io.Writer;
    
    	public static void main(String[] args) {
    
    		try{
    		Writer writer = null;
    		writer = new BufferedWriter(new FileWriter("age.tmp"));
    		
    		writer.write("21");
    		
    		}catch(Exception e){
    		}
    			
    	}
    Then you could use the Scanner class to get the age int value.
    Did this post help you? Please me! :cool:

  7. #7
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    java.io.BufferedWriter;
    java.io.FileWriter;

    dont exist in J2ME, on the java.io.Writer can import....

  8. #8
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    Apparently it isn't possible to create files in J2ME. If you need to store text, you can use Record stores...

    J2ME record management store
    Did this post help you? Please me! :cool:

  9. #9
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    thanks, will try it now...

  10. #10
    DonCash's Avatar
    DonCash is offline Moderator
    Join Date
    Aug 2007
    Location
    London, UK
    Posts
    240
    Rep Power
    9

    Default

    OK cool nice one. If you get it to work, please post your solution.
    Did this post help you? Please me! :cool:

  11. #11
    Sysem is offline Member
    Join Date
    May 2008
    Posts
    10
    Rep Power
    0

    Default

    looks like i got the code without errors, but when i run it using my sony ericsson emulator, i get an error The system cannot find the path specified.
    i can upload the entire ouput if you want...

    If i run it using the default emulator, there are no errors but nothing happens. It doesnt run.... Can anyone help on this 1?

Similar Threads

  1. Saving data...?
    By easyRyder in forum New To Java
    Replies: 8
    Last Post: 07-15-2008, 03:14 AM
  2. Replies: 0
    Last Post: 05-22-2008, 10:53 AM
  3. Replies: 4
    Last Post: 04-15-2008, 01:04 PM
  4. Saving application settings
    By mwildam in forum New To Java
    Replies: 0
    Last Post: 11-16-2007, 02:30 PM
  5. Saving Variables
    By Fish in forum New To Java
    Replies: 6
    Last Post: 06-25-2007, 08:20 PM

Posting Permissions

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