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 7502087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T20:44:55+00:00 2026-05-29T20:44:55+00:00

I would like app to add several (2k) words to UserDictionary. I have experimented

  • 0

I would like app to add several (2k) words to UserDictionary.

I have experimented with ContentResolver().insert/bulk insert….

// array of words
    String[] words = getResources().getStringArray(R.array.word_array); 

    Long start,end = null;

    start = System.currentTimeMillis();


    int len = words.length;
    ContentValues[] mValueArray = new ContentValues[len];
    ContentValues mNewValues = new ContentValues();

    mNewValues.put(UserDictionary.Words.APP_ID, "com.my.example");
    mNewValues.put(UserDictionary.Words.LOCALE, "en");
    mNewValues.put(UserDictionary.Words.FREQUENCY, "100");

    for (int i = 0; i < len; ++i) {

        mNewValues.put(UserDictionary.Words.WORD, words[i]);

        mValueArray[i] = mNewValues;
    }

    getContentResolver().bulkInsert(
            UserDictionary.Words.CONTENT_URI,   // the user dictionary content URI
           mValueArray                       // the values to insert
        );
   end = System.currentTimeMillis();

   Toast toast = Toast.makeText(this, "Time for " + Integer.toString(len-1)+" words: " + Long.toString((end-start)) + "ms", 50);
   toast.show();

On my phone takes about 100ms per word if I do bulkinsert on batches of 100. 3+ minutes to insert 2k words.

Is anyone aware of a faster method to insert words or any optimization that can be done?

Side question: Is there an upper limit on UserDictionary size or does that depend on phone?

Any help appreciated

Michealster

  • 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-05-29T20:44:57+00:00Added an answer on May 29, 2026 at 8:44 pm

    Specific to your case:
    Adding 2000 words in the dictionary at a stretch will take time and there is not much of an optimization which can be done. The time you see here are for the file operation and moving from Java->NDK->Native operation.

    General:
    Irrespective of the method used, one has to understand that these are nothing but file operations and is bound to take time. The APIs (including SQLite related) are just a wrapper to the intended file operations in the native code. Natively file write will always take a longer time then file read.

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

Sidebar

Related Questions

I have several active record models in a rails app and I would like
I would like to add OpenId support to an app. It runs on ASP.NET
I would like to add authentication to my Rails app. I came across few
I would like to add cpuid functionality to my C# app. I found this
I would like to add a custom alert sound to my iOS app. I
I would like some of my preferences to have icons, like the Settings app.
I would like to add SqlCacheDependency to my app. So I desided to create
I have a simple web app, it's done with several JSP pages. I would
I have a an app that has a UITabBarController . What I would like
I would like to develop a MS paint like app for the iPhone. Could

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.