Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8023255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:30:52+00:00 2026-06-04T22:30:52+00:00

I am loading Auto complete text view with data written in my csv file

  • 0

I am loading Auto complete text view with data written in my csv file but the file contains thousands of data, and hence it takes a lot of time to load, is there any way so that it can be done in background.
I have used Async task but can’t implement properly.

my code:

ArrayAdapter<String> TitleAdapter;

    protected Void doInBackground(Void... params) {

    readTitle();

    return null;
}

public void readTitle()

{
    InputStream is = _context.getResources().openRawResource(
            R.raw.title);
    InputStreamReader isr = new InputStreamReader(is);
    BufferedReader br = new BufferedReader(isr, 8192);
    try {
        String test;
        while ((test = br.readLine()) != null) {
            String[] RowData = test.split(",");
            String Title = RowData[0];

            TitleAdapter.add(Title);
        }
        isr.close();
        is.close();
        br.close();

    } catch (IOException e) {
        e.printStackTrace();

    }

}

my stack trace:

 03-01 15:06:35.396: ERROR/AndroidRuntime(572): FATAL EXCEPTION: AsyncTask #1
    03-01 15:06:35.396: ERROR/AndroidRuntime(572): java.lang.RuntimeException: An error    occured while executing doInBackground()
  03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at    android.os.AsyncTask$3.done(AsyncTask.java:200)
  03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.FutureTask.run(FutureTask.java:137)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.lang.Thread.run(Thread.java:1096)
03-01 15:06:35.396: ERROR/AndroidRuntime(572): Caused by: android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.view.ViewRoot.checkThread(ViewRoot.java:2802)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.view.ViewRoot.requestLayout(ViewRoot.java:594)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.view.View.requestLayout(View.java:8125)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.widget.AbsListView.requestLayout(AbsListView.java:993)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.widget.AdapterView$AdapterDataSetObserver.onChanged(AdapterView.java:790)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.database.DataSetObservable.notifyChanged(DataSetObservable.java:31)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.widget.BaseAdapter.notifyDataSetChanged(BaseAdapter.java:50)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.widget.ArrayAdapter.notifyDataSetChanged(ArrayAdapter.java:247)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.widget.ArrayAdapter.add(ArrayAdapter.java:179)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at com.Salary.Others.ReadFileHelper.readJobTitle(ReadFileHelper.java:111)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at com.Salary.Others.ReadFileHelper.doInBackground(ReadFileHelper.java:57)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at com.Salary.Others.ReadFileHelper.doInBackground(ReadFileHelper.java:1)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at android.os.AsyncTask$2.call(AsyncTask.java:185)
03-01 15:06:35.396: ERROR/AndroidRuntime(572):     at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)

i think this is because in doinbackground we can’t do any UI work.
So, how to handle this, is there any other way..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T22:30:53+00:00Added an answer on June 4, 2026 at 10:30 pm

    What is the problem, the long loading time or the crash log you’ve pasted in the question?

    If it’s the crash, you can’t call ArrayAdapter.add from a background thread, if the doInBackground method is a part of an AsyncTask, you can add onPostExecute to that AsyncTask which will run on the UI thread, and do the adds in that method.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having a problem with UIWebView auto-rotating. the web view straches alright but the
I'm loading items as an array of variables for the auto complete to work.
I have autoload.php . This is running for auto loading my classes. I want
While loading XML file in a C# application, I am getting Name cannot begin
When loading a CSS/JS file from CDN or any external server, it is possible
I wanted to add user search auto-complete (like Facebook's) to my Rails app on
I'm working on a jQueryMobile application with some form fields that need auto complete
I'm loading a file that has been saved by another class via the FileOutputstream
I'm trying to implement part of the facebook ads api, the auto complete function
I want to auto refresh result div with ajax & setInterval function. But there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.