Writing a preferences file

What I'm trying to do is very simple: I want to save the user's ' preferences' (at the moment, only two values of checkbox - this is it) in 'disc' such that the next time that the user running my app, their preferences are 'remember' by the application, I write.

import java. IO;
Net.rim.device.api.io import. *;

public static final void readPreferences() {}
int checkFullAuto, checkAutoSelect;
   
The preferences file still exist?
try {}
FileInputStream fis = new FileInputStream ("prefs.dat");
}
catch (FileNotFoundException e) {}
The file doesn't exist, then create it with the default values and return.
try {}
FileOutputStream fos = new FileOutputStream ("prefs.dat");
DataOutputStream back = new DataOutputStream (fos);
            
Based on the default values for the two check boxes, make calls like this:
dos.writeInt (1);
dos.writeInt (0);
           
Finish by writing to the file
back. Flush();
back. Close();
return;
}
{} catch (IOException f)
return;
}
}
    
The file * is * on the phone.  Finishing-opening then read its contents.
try {}
DataInputStream tell = new DataInputStream (fis);
       
Please = dis.readInt ();
checkTwo = dis.readInt ();
   
based on the above two values, set the values of the check boxes - code omitted to shorten
tell. Close();
return;
}
catch (IOException h) {}
Do nothing and get out this method gracefully if failure.

return;
}
}

I get the following errors to compile 3...

symbol: FileInputStream (java.lang.String) constructor
location: net.rim.device.api.io.FileInputStream of the class
FileInputStream fis = new FileInputStream ("prefs.dat");

cannot find symbol

symbol: FileOutputStream (java.lang.String) constructor
location: net.rim.device.api.io.FileOutputStream of the class
FileOutputStream fos = new FileOutputStream ("prefs.dat");
cannot find symbol

symbol: fis variable
location: Algorithms.Algorithms of the class
DataInputStream tell = new DataInputStream (fis);

I use BlackBerry JDE 4.6.0.12.  In the preferences--> Code signing tab, I checked 'RIM API of execution.'

What I am doing wrong?  If you see a better way to code this, please tell me;  I'd appreciate very much all the advice that you could give me!

Thank you very much...

Joe

Two things:

(a) it is scraping the bottom of my memory, but I think that the mechanism that you try to use ("FileConnection") is a former mechanism that has been a specific phone and type and is not generally supported.  I think you really want to use the FileConnection API - see the FileExplorer demo for more details.

(b) there are other ways to keep the user's preferences, in general, this is done using a persistent storage.  This has the advantage that you can store objects rather than having to serialize the data inbound and outbound bytes.

Tags: BlackBerry Developers

Similar Questions

  • Strange preference files

    Hello, I spent a few preference files (user ~ preferences) and have never seen such plists. These are familiar to anyone?

    I have the same game.

  • Set the format digital u32 when writing of TDMS files

    We use two meters of a PCI-6251, with two counters in the mode of angular position, to measure the angular positions of the two optical encoders 1000 per second for intervals of 10 to 20 hours.  We are writing to write files using PDM.  The files are very large, about 800 MB, but it is acceptable.  Convert us the TDMS files in .txt files, and then the data from .txt files are analyzed in Mathematica.

    My question is: How does one control the digital format of the data that is written in TDMS write?  At this moment we have two counters of the value of the product N = 10000 numbers U32 samples are then transmitted continuously to a TDMS file every 10 seconds.  The counters are using units of ticks (integers) and we would like to see whole in our data files.  We are convinced that the counters are producing U32 to the format number, since we see the correct U32 integers in the indicators on the front panel and we see labels on the value axis on our waveform graphs are integers, not real numbers.

    But it is also clear that Scripture TDMS puts double-precision (64-bit) numbers floating point in the PDM file, not numbers of U32.  The double-precision floating-point numbers cause our .txt files to be twice as big as they should be - these .txt files are half full with useless zeros and decimal points.  In addition, when you convert the U32 to double-precision real numbers, it seems to be a loss of precision as a result of writing of PDM, which is not acceptable.

    Our experience produces pairs of integers: U32 (or I32) format.  We could even get away with numbers I16.  Is it possible to get our data to stay in U32 (or same I16) format when they are written to the TDMS file?  What controls the digital numbers written to tdms?  Do all the numbers written in a PDM file end up being written as floating-point numbers double-precision?

    We use LabVIEW 8.2 on a PC running windows XP.

    If associate you TDMS write U32 data, data in the file will be U32. Floating-point conversion probably occurs when you read data from the file back. You can change this by plugging in a U32 empty table at the entrance of 'data type' reading PDM.

    You can check the data type in the file by examining the channel properties in the viewer of TDMS files. If NI_DataType is 7, given in the file are U32. If it is 10, data are floating point.

    Hope that helps,

    Herbert

  • all my components are grey in multisim11. Path to my configuration in the global preferences file is also grayed out, can not change the standard cfg

    all my components are grey in multisim11. Path to my configuration in the global preferences file is also grayed out, can not change the standard cfg

    Hi Escapermark,

    Take a look at these articles to the knowledge base, one should set the gray on the problem:

    http://digital.NI.com/public.nsf/allkb/609A763289E6E81D8625739F0052151F

    http://digital.NI.com/public.nsf/allkb/2719D00E36A4D53A8625721300685B3F

    http://digital.NI.com/public.nsf/allkb/B3D720348D55D0C5862575BA00560908?OpenDocument

  • Strange backup data by writing in the file measurment

    Hi all

    I developed a simple program that allows you to view the data from one channel, but it saves the data, just at the moment where the data backup button. Data is saved through writing on a file measurment, but unfortunately there is something wrong because the recorded data are strange. In the attachment, there is the file VI and the recorded data.

    As you can see there are several header and dates are strange (i.e. of the registration date 23/12/1916) and I get a lot more sample that I should have. Why do this?

    Any suggestion is appreciated.

    23/12/1916

    Your many headers is perhaps for this reason:

  • Error message - error 1310: error writing to the file: C:\Config.Msi\95cd7a.rbf

    I get the error message on the software updates: error 1310: error writing to the file: C:\Config.Msi\95cd7a.rbf.  Make sure you have access to this directory.  How can I fix it?  Thank you

    Hello

    ·          What version of the operating system is running on your computer?

    ·          What software you are trying to update?

    However, try the following steps:

    Unregister and re-register Windows Installer.

    a. Click Start and then click Run.

    (b) in the Open box, type msiexec /unreg and then press ENTER.

    c. Click Start and then click Run.

    (d) in the Open box, type msiexec/regserver, and then press ENTER.

  • Age of Mythology of installation met a disk error when writing in the file C:\Users\(my name)\Desktop\aom\textures\textures.bar

    Age of Mythology of installation met a disk error when writing in the file C:\Users\(my name)\Desktop\aom\textures\textures.bar. Make sure that your hard disk is not full, and that the file is not in use

    Original title: AOM moved only to 94%

    When I install Age of mythology, I have put on disc 1, do all the stuff, he moved to 45%, and then it asks me to put in disc 2. I do, and he moved to 94%, which is the stage that she calls 'Copy texture.bar' then it stops and I can hear the disc turn and stop repeatedly. After about 10-15 minutes, I get an error message and it said:

    "Age of Mythology of installation encountered a disk error when writing in the file.

    C:\Users\(My Name)\Desktop\aom\textures\textures.bar.

    Make sure that your hard disk is not full, and that the file is not in use. »

    I know that my hard disk is not full, because I just got this computer a month ago. In addition, when the disc is, it vibrates and makes a buzzing sound that only stopped when I put my finger on the space between the disc and the side of the laptop.

    Could you please help me?

    See if it's in the download of the demo. http://AOM.HeavenGames.com/

  • capture data using writing to the file position encoder

    Hello dear Sir

    can anyone help to check with my encoder to measure data?
    I connect the writing to the file of the measurement, but when I open the .txt file,.
    no result is, thank you very much for your help


  • How can I fix excerpt: error writing to the file and an unstable WiFi connection

    original title: How can I fix excerpt: error writing to the file

    Hello, I do not know anythingon fixing of my computer when I have problems. I looked at all the research sites and assistance, and none of them helped me with these problems and im getting ready to launch her aspire one mini laptop computer. im running xp and I bought it used and it has done this from day one. 2 weeks ago, that I got it. Please can you help me.

    How can I fix excerpt: error writing to the file C:docume~1\user\local~1\temp\nsvc.tmp\conduit-left.bmp

    and im having problems with my connection remaining on the port wireless what do I do, I can solve this problem too because I cannot even be in line for more then 5 minutes with the duty to stop and start over or repair the connection.

    For the first question, try to go to start | Programs | Accessories | System Tools | Disk Cleanup and that should clear of junk.  Then click Start | Run and type msconfig and disable the startup items, that you don't need, as many programs decide that they must run at startup and clutter the machine when they do not need to.  Also perform a defragmentation of the disk (under system tools also).  See if that helps with performance and other issues.

    Steve

  • "Error 1310" error writing to the file: c:\config.msi\f2046.rbf "while trying to install Adobe.

    Atitle: how to fix error 1310?

    We have vista and I get this error when I try to download adobe reader: 1310.error error writing to the file: c:\config.msi\f2046.rbf. How can I fix this error? Also had trouble to update old adobe, so I uninstalled, so now I have no adobe reader.

    Hello

    -Is the issue limited only when trying to install Adobe programs?
    -Did you do changes on the computer before this problem?
     
    Method 1: Run the FIXIT from Microsoft from the link below and check if the problem persists.
    Solve problems with programs that cannot be installed or uninstalled
     
    Method 2: I also suggest you to see the link below and check if that helps.
    Update errors. Acrobat, Reader | Windows
     
    Hope this information helps.
  • Your preference file is damaged or not valid google chrome unable to retrieve the settings

    Hello all,.

    I get this error message when loading google chrome via Windows 7: your preference file is damaged or not valid google chrome unable to retrieve the settings. Any suggestions please let me know.

    Kind regards

    Sugasaff

    Hello Sugasaff,

    Thanks for posting your query on the Microsoft Community.

    I would like to ask you:

    • The problem is specific to a single application?
    • Have you tried using Internet Explorer and check if it works well?

    You can try to uninstall and reinstall Chrome and check if it works very well.

    Refer,

    Uninstall or change a program

    To download and install again, see:

    https://www.Google.com/intl/en/chrome/browser/

    Hope this information was useful.

  • Writing a batch file which will remove some files?

    I'm writing a batch file which will remove some files based on a list in a text file. Each line lists a different file and a single line of the content of the files, as below:

    m:\trumpf3\ncdone\rueck090.txt:da,'1599','159934','159903400',1,1,1934
    m:\trumpf3\ncdone\rueck091.txt:da,'1599','159935','159903500',1,1,3518
    m:\trumpf3\ncdone\rueck092.txt:da,'CP_TAPESHOT',1
    m:\trumpf3\ncdone\rueck093.txt:da,'CP_TAPESHOT',1

    m:\trumpf4\ncdone\rueck440.txt:da,'*','480','0017341',1,1,2288, "
    m:\trumpf4\ncdone\rueck441.txt:da,'*','500','0017343',1,1,3705, "
    m:\trumpf4\ncdone\rueck442.txt:da,'*','510','0017344',1,1,3628, "
    m:\trumpf5\ncdone\rueck494.txt:da,'2179','217901','217900100',1,1,1500, "
    m:\trumpf5\ncdone\rueck495.txt:da,'2179','217902','217900200',1,1,707, "
    m:\trumpf5\ncdone\rueck496.txt:da,'2178','217801','217800100',1,1,1042, "
    m:\trumpf5\ncdone\rueck497.txt:da,'2178','217802','217800200',1,1,1383, "

    The first and the second file are two good files, however the third and fourth, I didn't need. At this point, I'll have to go through the list of files and manually delete each one that does not match the format of 1 & 2. They are in different folders, but I think that the path at the beginning should be able to make the batch to delete this file. I can just find a way so that it can go through the list in the text file. Any help would be greatly appreciated because that would be a huge timesaver.

    Well, I think even more easy.  Paste the whole lot into Excel to make it easier to handle. You can filter the lines manually, or write a formula next to him who decides whether the line should be understood, something like this:

    I don't know what criteria would you use, so I used 'if the number after that the parenthesis after the first comma is a number, keep the line."  The text surrounded by a circle is the text that I check to see if it is a number:

  • QFile writing in the file and trash to the first line

    Hello. Got this code, writing to the file

    RPL - QNetworkReply

       QString workingDir = QDir::currentPath();
        qDebug() << workingDir;
        QFile friendsData("data/friends.json");
        friendsData.open(QIODevice::ReadWrite | QIODevice::Text);
        QDataStream in(&friendsData);
        QByteArray ans = rpl->readAll();
        qDebug() << ans;
        in << ans;
        friendsData.close();
    

    And as a result I got

    With xml - the same thing.

    It was easy.
    * beep *, I forfot QTextStream rather QDataStream

  • Error writing to the file C:/Config.msi/93320.rbf (download iTunes 10.7)

    Error writing to the file C:/Config.msi/93320.rbf, make sure you have access to this directory.

    I am trying to download iTunes 10.7 but I see this error. How can I fix it?

    Hello

    Try to uninstall and reinstall the ITunes and check:

    Step 1: Uninstall the program

    Check out the link:

    Uninstall or change a program

    http://windows.microsoft.com/en-us/windows7/Uninstall-or-change-a-program.

    Step 2: Install the program

    Get the latest version of the program and install it and check if the problem persists.

    Check out the link:

    http://www.apple.com/asia/itunes/download/.

    Question still remains the same contact Apple Support.

    I hope that the above information is useful!

  • Delete InDesign preference files?

    If I click: delete InDesign preference files, I would lose other files (documents) in InDesign?

    NO.

Maybe you are looking for

  • How your brand itunes page

    I noticed that some shows have stigmatized see the pages and others are simple - they just album art. I searched for how to do this, but I have to be the dominant. Can someone point me in the right direction? Thank you.

  • passage of data container of teststand labwindows/cvi handle error

    Hello I'm moving a container of teststand parameter to labwindows/cvi using this UI API messages following this code created by Peter-r. example: https://decibel.NI.com/content/docs/doc-23332 It is a great example to start with, but as I run using wo

  • my Quick crash time any help

    Certain pgs whenever I go to Quick time accidents

  • I can't watch the video online

    When I go on a site like youtube, I can't watch a video. In the past, I had no problem, watch videos of all Web sites. I recently made an attempt of reduce the number of files etc... so I could reduce the use of my computer's memory. This process mad

  • Erreurd'application 0xc000007b

    Whenever text computer, I perceive a rectangle that reads as follows: error 0xc000007b application. The application has failed to start correctly. I don't know what to do pay make the rectangle disappear. Thank you in advance. Normand