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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:18:54+00:00 2026-05-17T00:18:54+00:00

I have a text field in SQLite database, which I want the user to

  • 0

I have a text field in SQLite database, which I want the user to be able to update.

So I extract and display the text in an EditText view. The user edits it and presses “Update” button. At this point I want to update the text field in database with whatever user has in the EditText.

Here’s the problem, EditText returns the type Editable.
And the put(String key, String value) function of ContentValues, that I use while updating the record, expects a String. So how to put an Editable in a String?

I tried upcasting the Editable to CharSequence and then casting that to String, but that gives me a runtime exception, ClassCastException, which it very well should (because the object was an Editable to begin with, I cannot make it a String).

So how to get around this? Here’s the code I am using. I know it is wrong, but I cannot figure out how to do this.

@Override
public void onClick(View v) {
   // update logic
   CharSequence strNewName = editTextName.getText();

  //Update record in the table
  ContentValues newRecord = new ContentValues();
  newRecord.put(GIDatabase.Students.NAME, (String strNewName); //ClassCastException here
  int rowsEffected = db.update(GIDatabase.Students.STUDENTS_TABLE_NAME, newRecord, GIDatabase.Students._ID + "=?", new String[]{strId});
if (rowsEffected != 1) {
    // This should never be reached                         
         throw new RuntimeException("Error updating name");
}

}

  • 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-17T00:18:55+00:00Added an answer on May 17, 2026 at 12:18 am

    This should do it:

    String.valueOf(editTextName.getText())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following text in SQLITE database in TEXT field The exact date of
I have a field X in my database which contains text values. My values
I have a SQLite database that has a time field set as a text
i have a text field in Contact screen and the user need to enter
Hi I have a text field which I would like to bind to a
I have a large SQLite database with a mix of text and lots of
I have a field (named as time, but type is TEXT) in my Sqlite
I have a ListView which contains a text field that is populated using a
For example: In my table I have text field with following text: The quick
I have a text field. If it has wrong values then it may show

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.