Hello.

I am using the example from the android development sites on outputstream 
to save a string to the internal storage, and I'm trying to get it with the 
use of inputstream.. But can't get it to work =/ What I want is to store a 
string and easily be able to get it from other activities, thats why I 
think this solution was the best. If you got any other solutions, please 
tell.

Anyway I am using this script, the string MyData is defined further up in 
the document as well as the filename. 

String filename = "testfile" //also tried "testfile.txt  
....
if (selectedItem.equals("Get")) {
        try {
         FileInputStream fis = new FileInputStream(filename);
         DataInputStream in = new DataInputStream(fis);
         BufferedReader br = new BufferedReader(
           new InputStreamReader(in));
         String strLine;
         while ((strLine = br.readLine()) != null) {
          myData = myData + strLine;
         }
         in.close();
        } catch (IOException e) {
         e.printStackTrace();
        }
   }
   if (selectedItem.equals("Post")) {
        String test = "5556";
        FileOutputStream outputStream;
        try {
         outputStream = openFileOutput(filename,
           Context.MODE_PRIVATE);
         outputStream.write(test.getBytes());
         outputStream.close();
        } catch (Exception e) {
         e.printStackTrace();
        }
   }

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Reply via email to