错误: Not sure how to handle query method‘s return type (long). UPDATE query methods must either re...

room_version=2.4.2 会报一下错误

下面是我的写的demo 中Dao部分
@Dao
interface CarBrandDao {
    // TODO 这里有BUG 返回suspend就会报错
    @Query("DELETE FROM CarBrandEntity")
    suspend fun clearCarBrand()

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertCarBrand(carBrandList: List<CarBrandEntity>)

    @Query("SELECT * FROM CarBrandEntity")
    fun getCarBrand():PagingSource<Int,CarBrandEntity>
}
在网上找了好久,才找到对应的解决方案,深渊巨坑,在之前的一个demo 中也遇到类似的问题,不过没有去处理,现在终于决绝。

解决方式一:

If you using kotlin version (1.7.0) should work with room latest alpha version (2.5.0-alpha02)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.0"

implementation "androidx.room:room-runtime:2.5.0-alpha02"
implementation "androidx.room:room-ktx:2.5.0-alpha02"
kapt "androidx.room:room-compiler:2.5.0-alpha02"

解决方式二:
If you want using room in stable version (2.4.2) should work with kotlin version (1.6.20)

classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.20"

implementation "androidx.room:room-runtime:2.4.2"
implementation "androidx.room:room-ktx:2.4.2"
kapt "androidx.room:room-compiler:2.4.2"
I have tried both and they work. this is the reference 

文章来源 原文---stackoverflowhttps://stackoverflow.com/questions/60050991/how-to-use-suspend-function-on-room-db

一下是对应的issues 

issueshttps://issuetracker.google.com/issues/236612358
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Learning Web Design: A Beginner’s Guide to HTML, CSS, JavaScript, and Web Graphics By 作者: Jennifer Robbins ISBN-10 书号: 1491960205 ISBN-13 书号: 9781491960202 Edition 版本: 5 出版日期: 2018-05-21 pages 页数: 808 英文原版超清 Do you want to build web pages but have no prior experience? This friendly guide is the perfect place to start. You’ll begin at square one, learning how the web and web pages work, and then steadily build from there. By the end of the book, you’ll have the skills to create a simple site with multicolumn pages that adapt for mobile devices. Each chapter provides exercises to help you learn various techniques and short quizzes to make sure you understand key concepts. This thoroughly revised edition is ideal for students and professionals of all backgrounds and skill levels. It is simple and clear enough for beginners, yet thorough enough to be a useful reference for experienced developers keeping their skills up to date. Build HTML pages with text, links, images, tables, and forms Use style sheets (CSS) for colors, backgrounds, formatting text, page layout, and even simple animation effects Learn how JavaScript works and why the language is so important in web design Create and optimize web images so they’ll download as quickly as possible NEW! Use CSS Flexbox and Grid for sophisticated and flexible page layout NEW! Learn the ins and outs of Responsive Web Design to make web pages look great on all devices NEW! Become familiar with the command line, Git, and other tools in the modern web developer’s toolkit NEW! Get to know the super-powers of SVG graphics Partl. Getting Started 1. Getting Started in Web Design D2. How the Web Works D3. Some Big Concepts You Need to Know Part ll. HTML for STRUCTURE 4. Creating a Simple Page D5. Marking Up Text D6. Adding Links 7. Adding lmages 8. Table Markup D9. Forms D10. Embedded Media Part ll. CSS for Presentation b11. Introducing Cascading Style Sheets 12. Formatting Text 13. Colors and Backgrounds b14. Thinking Inside the Box 15. Floating and Positioning D16. CSS Layout with Flexbox and Grid 17. Responsive Web Design D18. Transitions, Transforms, and Animation D19. More CSS Techniques D20. Modern Web Development Tools Part IV. JavaScript for Behavior D21. Introduction to JavaScript D22. Using JavaScript Part V. Web lmages D23. Web lmage Basics D24. Image Asset Production D25. SVG Part Vl. Appendices A. Answers B. HTML5 Global Attributes C. CSS Selectors, Levels 3 and4 DD. From HTML+to HTML5
The importance of good business writing skills cannot be underestimated. Here are some tips: 1. Remember the old public speaking adage: "Tell them what you're going to say, say it, then tell them what you said." The same principle holds when writing a business report. In an introductory paragraph (or section), tell your reader what you are going to say; in the body, say it; and in a concluding paragraph (or section), review what you have said. 2. Be excited by your topic. It shows! If you are not excited, you can be sure your readers will share your lack of enthusiasm. 3. Break up your writing with headings, subheadings, lists, tables, and figures. This helps the reader to understand and organize the content of your document. It is difficult to focus on and digest unrelieved text. 4. Proof-read, spell-check, and grammar-check your work! A good trick for proofreading is to read your report aloud in a conversational voice. Your tongue will often catch awkward phrases and words which your eyes might otherwise overlook. 5. Cite your sources of information and data, and include a reference list. A good and simple way to cite your sources is simply to include the name of the author and year of publication in parentheses within the body of your text (Lawrence 1999). Then include the full citation in a reference section at the end of your paper: The Ten Secrets of Writing a Business Letter: 1. Start From the End Decide what the result of your letter ought to be. List things you’d like to say, and review them. Remove those not supporting the main idea. Good letters have a strong sense of purpose. 2. Get to the Point Early Don’t delay. You should state your main cause in the first paragraph. 3. Put Yourself in Your Reader’s Place If the letter came to you, how would you respond? Be pleasant; try to turn negative statements into positive ones. 4. Say it Plainly Phrases like “in compliance with your request” and “enclosed herewith” are stilted. Write as you talk — naturally. Include just one idea. Sentences longer than two typed lines are suspect. 5. Clear the Deadwood Cut words, sentences, and even paragraphs that don’t contribute. Work hard to simplify your reader’s job. Be especially careful with adjectives, which can sap strength from your words. 6. Use Active Verbs Passive voice is weak and confusing. “A decision has been reached by the committee” is inferior to “The committee has reached a decision.” Also, readers can sense your evasiveness if you write: “Your order has been misplaced” instead of “I misplaced your order.” 7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A 7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A7. Be Human Your letter should read like a conversation. Address your reader by name: “Dear Ms. Hartman.” And if you can fit it in naturally, use Ms. Hartman’s name in the body. You want her to know the letter is personal. Whenever you can, use pronouns like I, we, and you. 8. Never Write in Anger Anger will evaporate; a letter won’t. Devise a way to handle problems in an upbeat manner. Your chances of success will multiply tenfold. 9. End With an Action Step The end of a letter should suggest the reader’s next move, or your own. Don’t write distracting closings like: “Again, thank you for . . .” or “If you have problems, please don’t hesitate to call.” Close with a simple “Sincerely,” and your signature; it may be a perfect ending. 10. Be Professional The most well-written letters can’t survive bad presentation. Use a clean, logical format for your letter. A crowded or over-designed page distracts from your message.
It seems like you are trying to return a List of ImageInfo objects from the method `getALLUsers()` in the `SecondActivity` class. However, you are getting an error related to converting a Cursor object to the return type. To fix this error, you need to fetch the data from the Cursor object and convert it into a List of ImageInfo objects. Here's an example of how you can do this: ``` public List<ImageInfo> getALLUsers() { SQLiteDatabase db = this.getReadableDatabase(); List<ImageInfo> imageInfoList = new ArrayList<>(); String[] projection = {...}; // Define the columns you want to fetch String sortOrder = "..."; // Define the sort order of the results Cursor cursor = db.query( TABLE_NAME, projection, null, null, null, null, sortOrder ); while (cursor.moveToNext()) { // Extract the data from the cursor and create a new ImageInfo object ImageInfo imageInfo = new ImageInfo(); imageInfo.setId(cursor.getInt(cursor.getColumnIndexOrThrow(COLUMN_ID))); imageInfo.setName(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_NAME))); imageInfo.setPath(cursor.getString(cursor.getColumnIndexOrThrow(COLUMN_PATH))); // Add the ImageInfo object to the list imageInfoList.add(imageInfo); } cursor.close(); return imageInfoList; } ``` In this example, we are using the `query()` method to fetch all rows from the database table and store them in a Cursor object. Then, we iterate over the cursor using a while loop and extract the data from each row to create a new ImageInfo object. Finally, we add the ImageInfo object to a List and return the list.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值