0

I downloaded a library. It is a Rich Text Editor Library. But when I replaced it with my old EditText, I couldn't access the text-related properties of my EditText. Like doAfterTextChanged, myEditText.text, myEditText.setText() etc. Thats my first problem.

When I use this I am wondering how I can save it to my database as string with its format properties. When I searched for this on the web, I found something called varchar, but I don't know if room supports it, even if it does, I don't know how to save it as varchar. And thats my second problem.

What should i do?

1
  • 1
    This is two questions in one. 1) You'll need to update your code to use the editor library API. 2) You'll need to see how that library exposes the formatted text and take it from there.. Commented Feb 21, 2023 at 17:10

1 Answer 1

0

In room library you must create 3 things:

  1. Singltone instanse of your database

  2. Data access object(DTO)

  3. Entity for your data You can read about entits and room db here

    @Entity(tableName = "tasks") data class TaskEntity( @PrimaryKey(autoGenerate = true) val id: Int?, @ColumnInfo(name = "list_id") val listId: Int?, @ColumnInfo(name = "task_name") val taskName: String?, @ColumnInfo(name = "task_price") val taskPrice: Float = 0.0F, )

This is entity example. Then defined filed of dataclass as String room will create varchar column automatically

Sign up to request clarification or add additional context in comments.

3 Comments

Then how can i reach the formatted text's text as varchar. Because when i tried to do something like "saving.text = myText.text" i cant reach myText's text so i cant save it. What should i do at this point? So how can i reach my Formatted EditText's varchar?
@AhmetKaan must be saving.text = myText.text.toString() also VARCHAR is simple string definition,but in sql syntax @Query("SELECT string FROM your_table WHERE id = :id") fun getAllByListId(id: Int): String Some DAO like this return you string from your VARCHAR field
But i cant reach directly .text or its variations methods. I'm getting this error when i tried "saving.text = myText.text.toString()"; "Unresolved reference text". What can i do at this point? I am also using setText, doAfterTextChanged. And none of them is working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.