android-room

Room not creating database in UI-Tests

风格不统一 提交于 2020-01-16 01:08:10
问题 I am using a Room database inside my project and it works in production including the UI-Tests (with Espresso) until Android 8. On Android 9 currently my UI-Tests fail because the Database is not created. I get the following error message inside my logcat android.database.sqlite.SQLiteException: no such table: table (code 1 SQLITE_ERROR): , while compiling: SELECT * FROM table WHERE type = ? This only happens on Android 9 devices. While debugging with Stetho i can't find the db file aswell.

“Cannot access database on the main thread since it may potentially lock the UI for a long period of time.” error on my Coroutine

♀尐吖头ヾ 提交于 2020-01-15 14:25:34
问题 My Coroutine is running on the main thread, which i've specified in my Coroutine context: class ClickPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs), CoroutineScope, View.OnClickListener { override val coroutineContext: CoroutineContext get() = Dispatchers.Main override fun onClick(v: View?) { when (key){ "logout" -> { CoroutineScope(coroutineContext).launch { CustomApplication.database?.clearAllTables() Log.d("MapFragment", "Cleared Tables") } if (Profile

Android Room Generic DAO

强颜欢笑 提交于 2020-01-15 08:10:53
问题 Good day Stack, i'm working on an Android project that uses Android's Room 1.0.0 Alpha 5, the main issue that i'm facing is that every time i need to call one of the DAO from room i need to do something like this: Activity.java: ... AppDatabase db = Room.databaseBuilder(context, AppDatabase.class, "Storage").build(); Table1 table = new Table1(); table.setId(1); table.setName("Hello"); new AccessDB().execute(1); /* Generic AccessDB needed */ private class AccessDB extends AsyncTask<Integer

Android Room Generic DAO

安稳与你 提交于 2020-01-15 08:09:15
问题 Good day Stack, i'm working on an Android project that uses Android's Room 1.0.0 Alpha 5, the main issue that i'm facing is that every time i need to call one of the DAO from room i need to do something like this: Activity.java: ... AppDatabase db = Room.databaseBuilder(context, AppDatabase.class, "Storage").build(); Table1 table = new Table1(); table.setId(1); table.setName("Hello"); new AccessDB().execute(1); /* Generic AccessDB needed */ private class AccessDB extends AsyncTask<Integer

Android Room Generic DAO

北慕城南 提交于 2020-01-15 08:09:00
问题 Good day Stack, i'm working on an Android project that uses Android's Room 1.0.0 Alpha 5, the main issue that i'm facing is that every time i need to call one of the DAO from room i need to do something like this: Activity.java: ... AppDatabase db = Room.databaseBuilder(context, AppDatabase.class, "Storage").build(); Table1 table = new Table1(); table.setId(1); table.setName("Hello"); new AccessDB().execute(1); /* Generic AccessDB needed */ private class AccessDB extends AsyncTask<Integer

Android Studio does't check/highlight Kotlin Room DAO queries when string occupies more than 1 row

让人想犯罪 __ 提交于 2020-01-14 10:27:08
问题 When I'm trying to break query for better readability/comprehension it stops being checked by IDE. This occurs on Android Studio 3.2 canary 16 and 3.1.2 stable, kotlin version 1.2.41. When Room DAO is java class/interface everything works fine. Is it possible to have the same checking/highlighting for 2+ rows queries in kotlin as in java? 回答1: This is supposed to be resolved in AS 3.6, but, for now, the workaround noted at https://issuetracker.google.com/issues/130141151#comment3 does the

Calling custom SQLite functions in Room

前提是你 提交于 2020-01-13 18:06:57
问题 I include a custom build of sqlite in my app. I have several custom functions in that library, and I would like to call them from @Query in my Room DAOs. However I get an error that Room couldn't find those functions. Is there a way to tell Room that they exist WITHOUT using a @RawQuery? 回答1: From Google: Room can't verify queries with custom functions, please annotate your method with @SkipQueryVerification . Room verifies your Dao queries using sqlite-jdbc which uses a vanilla prebuilt

Calling custom SQLite functions in Room

心不动则不痛 提交于 2020-01-13 18:04:03
问题 I include a custom build of sqlite in my app. I have several custom functions in that library, and I would like to call them from @Query in my Room DAOs. However I get an error that Room couldn't find those functions. Is there a way to tell Room that they exist WITHOUT using a @RawQuery? 回答1: From Google: Room can't verify queries with custom functions, please annotate your method with @SkipQueryVerification . Room verifies your Dao queries using sqlite-jdbc which uses a vanilla prebuilt

Refresh data from a network using LiveData

纵饮孤独 提交于 2020-01-13 10:13:53
问题 I am working on an app that queries the github api to get a list of user and i'm following the recommended android architecture component guide. Once the data is fetched from the network, I store it locally using Room DB and then display it on the UI using ViewModel that observes on the LiveData object (this works fine). However, I want to be able to have a button which when clicked would trigger a refresh action and perform a network request to get new data from the API if and only if there

Refresh data from a network using LiveData

試著忘記壹切 提交于 2020-01-13 10:12:07
问题 I am working on an app that queries the github api to get a list of user and i'm following the recommended android architecture component guide. Once the data is fetched from the network, I store it locally using Room DB and then display it on the UI using ViewModel that observes on the LiveData object (this works fine). However, I want to be able to have a button which when clicked would trigger a refresh action and perform a network request to get new data from the API if and only if there