简体   繁体   中英

Best way to implement reading data

I'm currently making my first app and have a few questions on the best approach to implement it.

On the main menu there is a button, when this is clicked I would like it to display items in a list read in from a text file. Should I add the relevant info into an ArrayList to display the info in the list, or obtain the info then create an object and then add the object to the ArrayList.

I need to save the info read in for the next activity as I want to display more info about the item which has been clicked on in multiple other activities.

The only thing is that a couple of the files contain upto 6000 lines of info and I'm not sure on the best approach.

I know that SQL Lite is one option but the file format is quite obscure.

Another thing is that depending on the button clicked different different it would read from different files.

I would like to avoid have lots of duplicate code for each activity, could any one help me on the best way to organise the classes etc.

Thank you.

Only the first two item's are required for the list, however I need the rest of the info for another activity.

Some files may also have to be written to.

I developed a program that has to read info from text files (20000 lines). At the beginning I had just 1 text file, but the problem is that java can't just jump to a specified line and read it quickly, so the app took some time. Then I decided to fragment the data in 20 files (1000 lines each) and that works pretty good. If I was you, I would have 3 files with 2000 lines each (or 6 with 1000 lines) in the assets folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM