read csv file in android

I want to read a csv file from a specific path , but the code does not show me the contents of the file without receiving an error (if when I add the csv file to the program source and the asset folder,The contents of the file are displayed in textview without any problem)

This is my code:

try{File sdCard = Environment.getExternalStorageDirectory();
    File dir = new File (sdCard.getAbsolutePath() + "/dl");
    File cert = new File(dir,"m.csv");
    
    InputStream sl = new BufferedInputStream(new FileInputStream(cert));

    

BufferedReader reader=new BufferedReader(
    new InputStreamReader(sl,Charset.forName("UTF-8")));


String line="";



while((line=reader.readLine())!=null){
        String[] token;
        token=line.split(",");
        

for(int i=0;i<token.length;i++){
        dt.sets2(token[i]+"-");
        s=dt.gets1();
        if(token[i].length()>15){
            s=dt.gets2()+"---";
        }
        
        }
        tv.setText(s+"token lrn"+Integer.toString(token.length));
        
        weathersam.add(dt);
    
        }
        
        
        
        
        }catch(Exception e){
            error=e.getMessage();
            Log.d("iii", e.getClass().getSimpleName() + ": " + e.getMessage());
        }


Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation