Question

My problem with the software I'm trying to make is this; when I save the information, it's saved with this code:

Code i save

With this, the information is saved in a text in the SD, but I couldn't to read that information. I've tried with several ways.

I want to save the content of the TXT in a String to put it in a TextView.

Was it helpful?

Solution 2

        I have tried this code and it works perfectly :D

File ruta_sd = Environment.getExternalStorageDirectory(); File f = new File(ruta_sd.getAbsolutePath(), "datos.txt");

      BufferedReader fin =new BufferedReader(
              new InputStreamReader(
                      new FileInputStream(f)));
      String texto = fin.readLine();
      fin.close();

      textohere.setText(texto);

OTHER TIPS

try 
            {
                String myData ;
                FileInputStream fis = new FileInputStream(your file name);
                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();
               }
               // play with myData..It's file content
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top