База данных Room не отображается в Base Inspector
Entity:
package com.example.myapplication
import androidx.room.Database
import androidx.room.Room
import androidx.room.RoomDatabase
import android.content.Context
@Database(entities = [note::class],version = 1)
abstract class notesdb : RoomDatabase() {
abstract fun gdao(): notedbDao
companion object{
fun notedbfunc(context: Context): notesdb{
return Room.databaseBuilder(
context.applicationContext,
notesdb::class.java,
"notes.db"
).build()
}
}
}
Dao:
package com.example.myapplication
import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
@Dao
interface notedbDao {
@Insert
fun insertnote(note: note)
@Update
fun updatenote(note: note)
@Query("SELECT * FROM note")
fun getAllnotes(): List<note>
}
Создание и запись:
val db = notesdb.notedbfunc(this)
var note = arrayOf(note(null,"firstnamenote","note"),note(null,"secondnamenote","note"),note(null,"thirdnamenote","note"))
Thread{
db.gdao().insertnote(note[0])
db.gdao().insertnote(note[1])
db.gdao().insertnote(note[2])
}
в чом ошибка? также не получается посмотреть базу данных вручную? из-за отсутствия папок /data/data в файлах эмулятора
также видоизменил код, в такой:
val db = notesdb.notedbfunc(this)
var note = arrayOf(note(null,"firstnamenote","note"),note(null,"secondnamenote","note"),note(null,"thirdnamenote","note"))
println("vnvesdljlsjldk")
Thread{
db.gdao().insertnote(note[0])
db.gdao().insertnote(note[1])
print("phgjhgjhgjgj")
println(db.gdao().getAllnotes())
}
вывод:
12/16 11:50:46: Launching 'app' on Pixel 3 XL API 33.
Install successfully finished in 203 ms.
$ adb shell am start -n "com.example.myapplication/com.example.myapplication.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Connected to process 6284 on device 'Pixel_3_XL_API_33 [emulator-5554]'.
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/e.myapplication: Late-enabling -Xcheck:jni
W/e.myapplication: Unexpected CPU variant for x86: x86_64.
Known variants: atom, sandybridge, silvermont, kabylake, default
W/e.myapplication: Suspending all threads took: 29.799ms
V/studio.deploy: Startup agent attached to VM
V/studio.deploy: No existing instrumentation found. Loading instrumentation from instruments-6b5afa68.jar
W/e.myapplication: DexFile /data/data/com.example.myapplication/code_cache/.studio/instruments-6b5afa68.jar is in boot class path but is not in a known location
V/studio.deploy: Applying transforms with cached classes
W/e.myapplication: Redefining intrinsic method java.lang.Thread java.lang.Thread.currentThread(). This may cause the unexpected use of the original definition of java.lang.Thread java.lang.Thread.currentThread()in methods that have already been compiled.
W/e.myapplication: Redefining intrinsic method boolean java.lang.Thread.interrupted(). This may cause the unexpected use of the original definition of boolean java.lang.Thread.interrupted()in methods that have already been compiled.
D/CompatibilityChangeReporter: Compat change id reported: 171979766; UID 10159; state: ENABLED
W/re-initialized>: type=1400 audit(0.0:27): avc: granted { execute } for path="/data/data/com.example.myapplication/code_cache/startup_agents/69880af5-agent.so" dev="dm-33" ino=140297 scontext=u:r:untrusted_app:s0:c159,c256,c512,c768 tcontext=u:object_r:app_data_file:s0:c159,c256,c512,c768 tclass=file app=com.example.myapplication
D/nativeloader: Configuring classloader-namespace for other apk /system_ext/framework/androidx.window.extensions.jar. target_sdk_version=33, uses_libraries=ALL, library_path=/data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication
D/nativeloader: Configuring classloader-namespace for other apk /system_ext/framework/androidx.window.sidecar.jar. target_sdk_version=33, uses_libraries=ALL, library_path=/data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication
W/ziparchive: Unable to open '/data/data/com.example.myapplication/code_cache/.overlay/base.apk/classes6.dm': No such file or directory
W/ziparchive: Unable to open '/data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/base.dm': No such file or directory
W/ziparchive: Unable to open '/data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/base.dm': No such file or directory
D/nativeloader: Configuring classloader-namespace for other apk /data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/base.apk. target_sdk_version=33, uses_libraries=, library_path=/data/app/~~GRgdjjmM4xQqRDRbeQ2-5g==/com.example.myapplication-1p2dno9wBoFSRLSFYX4Bhw==/lib/x86_64, permitted_path=/data:/mnt/expand:/data/user/0/com.example.myapplication
V/GraphicsEnvironment: ANGLE Developer option for 'com.example.myapplication' set to: 'default'
V/GraphicsEnvironment: ANGLE GameManagerService for com.example.myapplication: false
V/GraphicsEnvironment: Neither updatable production driver nor prerelease driver is supported.
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/NetworkSecurityConfig: No Network Security Config specified, using platform default
D/libEGL: loaded /vendor/lib64/egl/libEGL_emulation.so
D/libEGL: loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
D/libEGL: loaded /vendor/lib64/egl/libGLESv2_emulation.so
D/CompatibilityChangeReporter: Compat change id reported: 171228096; UID 10159; state: ENABLED
D/CompatibilityChangeReporter: Compat change id reported: 210923482; UID 10159; state: ENABLED
W/e.myapplication: Accessing hidden method Landroid/view/View;->computeFitSystemWindows(Landroid/graphics/Rect;Landroid/graphics/Rect;)Z (unsupported, reflection, allowed)
W/e.myapplication: Accessing hidden method Landroid/view/ViewGroup;->makeOptionalFitsSystemWindows()V (unsupported, reflection, allowed)
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0x7b2aefbb8f10, tid 6320
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
W/OpenGLRenderer: Failed to initialize 101010-2 format, error = EGL_SUCCESS
D/EGL_emulation: eglCreateContext: 0x7b2aefbb9390: maj 2 min 0 rcv 2
D/EGL_emulation: eglMakeCurrent: 0x7b2aefbb9390: ver 2 0 (tinfo 0x7b2d1b4ec080) (first time)
I/Gralloc4: mapper 4.x is not supported
D/HostConnection: createUnique: call
D/HostConnection: HostConnection::get() New Host Connection established 0x7b2aefbb7590, tid 6320
D/goldfish-address-space: allocate: Ask for block of size 0x100
D/goldfish-address-space: allocate: ioctl allocate returned offset 0x3e7ffe000 size 0x2000
W/Gralloc4: allocator 4.x is not supported
D/HostConnection: HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_direct_mem ANDROID_EMU_host_composition_v1 ANDROID_EMU_host_composition_v2 ANDROID_EMU_vulkan ANDROID_EMU_deferred_vulkan_commands ANDROID_EMU_vulkan_null_optional_strings ANDROID_EMU_vulkan_create_resources_with_requirements ANDROID_EMU_YUV_Cache ANDROID_EMU_vulkan_ignored_handles ANDROID_EMU_has_shared_slots_host_memory_allocator ANDROID_EMU_vulkan_free_memory_sync ANDROID_EMU_vulkan_shader_float16_int8 ANDROID_EMU_vulkan_async_queue_submit ANDROID_EMU_vulkan_queue_submit_with_commands ANDROID_EMU_sync_buffer_data ANDROID_EMU_read_color_buffer_dma ANDROID_EMU_hwc_multi_configs GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_2
W/Parcel: Expecting binder but got null!
I/System.out: vnvesdljlsjldkfjlfjsldjflksjflsjlfjslfjljflklfjsldjflksjflksjflskfj
D/EGL_emulation: app_time_stats: avg=146.09ms min=3.90ms max=944.55ms count=8
функции в потоках, ничего не делают и не выводят