Android Adventures–Development Tips-Parte 3

How to shrink activity layout when virtual keyboard is displayed and hides some of the views?
There are several different solutions, one of them is:

– In the AndroidManifest.xml, for the target activity

android:windowSoftInputMode=”adjustResize”

If you use Database Room framework for SQLite management and Kotlin:

If you are using Kotlin don’t create a new method, you can have compilation errors on the generated class

java.lang.IllegalStateException: Cannot access database on the main thread since it may potentially lock the UI for a long period of time.
Solution 1: add allowMainThreadQueries

MyApp.database =  Room.databaseBuilder(this, AppDatabase::class.java, “MyDatabase”).allowMainThreadQueries().build()

Solution 2: Use another thread

Solution 3: If you use Kotlin 1.3+ you can use coroutines

How to explore a database in Android Emulator?
– You can copy the db files from the device to your computer and use a sqlite browser

– I use: Android Debug Database: https://github.com/amitshekhariitbhu/Android-Debug-Database

Bad Behavior has blocked 62 access attempts in the last 7 days.

Hyper Smash