How to read a text file from the server

advertisements

I have A Text file of 15 MB that is available on the server. I don't want tor Download that file. My file is arranged with the index . User search any word from the online file. I am confused about that how i can read online text file, Here is the code that i am using, but there is OutOfMemoryError.

        final Handler mHandlr=new Handler();

        new Thread(new Runnable() {

            @Override
            public void run() {
                String d=getStringFromUrl(TafseerEngPath);
                tafseerTxt.setText(getJSONFromUrl(TafseerEngPath));
                mHandlr.post(new Runnable() {

                    @Override
                    public void run() {
                        tafseerTxt.setText(getJSONFromUrl(TafseerEngPath));
                    }
                });
            }
        }).start();

Error 12-31 18:08:01.100: E/AndroidRuntime(11052): java.lang.OutOfMemoryError


You have stored your data as Text format and you want to retrieve it as some piece of information at a time. This is not possible with TextFormat ( partially it is possible by creating a webservice ). To avoid this I would like suggest you to store your words in mysql and access the data with webservice.

Android and PHP Web Service.