Search code examples
javaandroidfilesd-card

Read a .txt file of SD in Android


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.


Solution

  •         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);