Skip to content
Advertisement

How to print data from csv file onto secondactivity?

I’m creating an app which has a csvfile stored in its Raw resource folder and when I click on a button in main Activity , it should print the data of the csvfile in second Activity. But when I launch the app and then launch the second activity using a button ,its output is blank…

I have tried using various codes from stack overflow but I was not able to achieve the desired result. My csv File is really long, but I have kept a portion of it in here , so pls bear with me 😉 :

JavaScript

This is my code:-

MainActivity.java

JavaScript

SecondActivity.java

JavaScript

So am I missing something like a create a separate java class for the csv file or is some of my code missing something??? Pls help , because I am just trying to learn some coding and also do this correctly.

Also by the way, I want to display the csv file in a list view on SecondActivity.

Advertisement

Answer

@Nachiketa,

I have tried your shared code and modified using asset manager and able to see the data in the logcat. Please see the below code,

JavaScript

Please check this and mark as answered, if solves your problem.

Thanks

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement