App crash on reading data from file of 2 Mb

+1 Usman Mohy ud Din · November 6, 2014
Hy everyone

i need suggestion to improve my code.

I am reading a text file of size 1 mb line by takes 15 seconds to read that file and store the values in tier datastructure.while app crash when size of file is 2 mb or larger.

Is there any faster way to read entire file of size 2 mb....??
Thanks in advance...

My code is...

ContextWrapper ctx = ReadTextFileActivity.this;
int resId = R.raw.books;
InputStream inputStream = ctx.getResources().openRawResource(resId);

InputStreamReader inputreader = new InputStreamReader(inputStream);
BufferedReader bufferedreader = new BufferedReader(inputreader);
String line;

try {
while ((line = bufferedreader.readLine()) != null) {

} catch (Exception e) {

Post a Reply


Oldest  Newest  Rating
0 Usman Mohy ud Din · November 7, 2014
I am thinking to add two, three screens like splash,menu screens etc just before the word making screen.
0 Alex Sweps · November 7, 2014
Hmmm are you able to put a loading screen up with some flashy graphics and a loading bar?
0 Usman Mohy ud Din · November 7, 2014
even if i use threads to load data (2 Mb) it will take 20 seconds.
I am working on a word game just like Word with Friends.First of all app read words from text file and load load into Trie data structure. When user form word, app check this word is valid or not. app responses user in nanoseconds.
The only problem i am facing is loading data into Trie.

I want some favour to suggest me regarding...

every time when app starts, user has to wait 20 seconds for loading data.How i overcome this or indulge user in some activity so that loading of completed.??
Is it good approach to directly use Trie data structure and not using database?
0 Alex Sweps · November 6, 2014
Yeah I had a similar issue with some sound files a while ago. I got around it by loading it in another thread when the app started. It still didnt fix my original issue but it stopped the crash.

I have no idea where that code is now either...  
  • 1

Java / Android Development


Very popular language used to create desktop applications, website applets, and Android apps.

Bucky Roberts Administrator