android - using big files from res/raw -


i trying develop dictionary application uses source files res/raw. works when use smaller file, not file have use cca 5mb.

i decided split in parts , use way because appears android has file size limits assets folder(1mb?). doesnt work way, loads in program not dictionary files. seems problem? going in wrong way this?

    private void loadwords() throws ioexception {         final resources resources = mhelpercontext.getresources();         inputstream inputstream = resources.openrawresource(r.raw.definitions1);         bufferedreader reader = new bufferedreader(new inputstreamreader(inputstream));         ucitaj(reader);          inputstream inputstream2 = resources.openrawresource(r.raw.definitions2);         bufferedreader reader2 = new bufferedreader(new inputstreamreader(inputstream2));         ucitaj(reader2);          inputstream inputstream3 = resources.openrawresource(r.raw.definitions3);         bufferedreader reader3 = new bufferedreader(new inputstreamreader(inputstream3));         ucitaj(reader3);          inputstream inputstream4 = resources.openrawresource(r.raw.definitions4);         bufferedreader reader4 = new bufferedreader(new inputstreamreader(inputstream4));         ucitaj(reader4);          inputstream inputstream5 = resources.openrawresource(r.raw.definitions5);         bufferedreader reader5 = new bufferedreader(new inputstreamreader(inputstream5));         ucitaj(reader5);          inputstream inputstream6 = resources.openrawresource(r.raw.definitions6);         bufferedreader reader6 = new bufferedreader(new inputstreamreader(inputstream6));         ucitaj(reader6); 

--

  private void ucitaj(bufferedreader reader) throws ioexception {         log.d(tag, "loading words...");         try {             string line;             while ((line = reader.readline()) != null) {                 string[] strings = textutils.split(line, " -- ");                 if (strings.length < 2) continue;                 long id = addword(strings[0].trim(), strings[1].trim());                 if (id < 0) {                     log.e(tag, "unable add word: " + strings[0].trim());                 }             }         } {             reader.close();         }         log.d(tag, "done loading words.");     } 

i'm pretty sure - chunking several resources useless, since anyway you're reading in end files ram/heap, size limited. in resembling situation (i need show in textview relatively large text) had overcome situation using special class implementing charsequence interface. in fact charsequence has several abstract methods can used chunking/positioning in big file necessary fragments, like:

abstract char charat(int index) abstract charsequence subsequence(int start, int end) 

probably in situtation might help.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

html - Instapaper-like algorithm -

c# - How to execute a particular part of code asynchronously in a class -