Как отладить «ошибку SQL (запрос) или отсутствующую базу данных» в приложении для Android?

10-02 01:31:57.697 22242-22242/com.example.android.mynotes E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.android.mynotes, PID: 22242 java.lang.IllegalStateException: Could not execute method for android:onClick at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: java.lang.reflect.InvocationTargetException at java.lang.reflect.Method.invoke(Native Method) at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) at android.view.View.performClick(View.java:5697) at android.widget.TextView.performClick(TextView.java:10826) at android.view.View$PerformClick.run(View.java:22526) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120) Caused by: android.database.sqlite.SQLiteException: near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT); ################################################################# Error Code : 1 (SQLITE_ERROR) Caused By : SQL(query) error or missing database. (near "EXISTName": syntax error (code 1): , while compiling: CREATE TABLE IF NOT EXISTName(ID INTEGER PRIMARY KEY,TitleTEXT,DescriptionTEXT);) ################################################################# at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method) at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:1058) at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:623) at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588) at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:59) at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31) at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1812) at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1743) at com.example.android.mynotes.DbManager$DatabaseHelperNotes.onCreate(DbManager.kt:32) at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251) at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163) at com.example.android.mynotes.DbManager.<init>(DbManager.kt:22) at com.example.android.mynotes.AddNotes.BtnAdd(AddNotes.kt:19) ... 12 more 

 CREATE TABLE IF NOT EXISTName 

Вам не хватает пробела между ключевым словом EXIST и именем таблицы Name .

Вы можете просто добавить блок кода в блок try-catch, а затем поместить на него точку отладки и определить исключение и исправить его.

например

 try { //block of code in which you have an error or you want to debug } catch(e: Exception) { // you can use log for seeing error or you can simply view errors by //putting debug point and pressing alt+mouse_left_click after executing //line to get value of exception instance }