• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps another problem...:) a program crashes... help !

iggy23

Newbie
upload_2017-2-24_20-41-4.png

upload_2017-2-24_20-42-41.png



So i have created menu, mainactivity, databasehelper... but when i start the application.. first it says that the app didnt start and if i want to retry... then it says that the app is crashed...

i dont know where to find the error code , so maybe you can see it here?
 
Mate I told you this in your previous thread. So I'll repeat it here:
Don't use screenshots for stack traces. You're cutting off all the information needed to diagnose the problem.
Use [code][/code] tags to contain your code text.

Nobody can help you if you don't follow these basic instructions.
 
There's a problem in your DatabaseHelper class. Please post the code, enclosed in [code][/code] tags.
 
i doesn´t under stand what you mean with
Code:
tag :D

i can show you my databasehelperclass ..:

upload_2017-2-24_21-34-17.png

upload_2017-2-24_21-34-30.png


screenshots again.. :D
 
i doesn´t under stand what you mean with tag :D
Try:

[code]
public class HelloWorld {
public static void main(String[] args) {
// Prints "Hello, World" to the terminal window.
System.out.println("Hello, World");
}
}
[/code]

It makes your code much easier to read than trying to follow screenshots. :thumbsupdroid:
Code:
public class HelloWorld {
    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");
    }
}
 
Code:
public class DatabaseHelper extends SQLiteOpenHelper {
    public static final String DATABASE_NAME ="Zalgiris Kaunas";
    public static final String TABLE_NAME = "Zalgiris_table";
    public static final String COL_1 = "ID";
    public static final String COL_2 = "NAME";
    public static final String COL_3 = "LASTNAME";
    public static final String COL_4 = "AGE";
    public static final String COL_5 = "BIRTHDATE";
    public static final String COL_6 = "HEIGHT";
    public static final String COL_7 = "WEIGHT";
    public static final String COL_8 = "SKILL_LVL";
    public static final String COL_9 = "POSITION_FIRST";
    public static final String COL_10 = "POSITION_SECOND";

public DatabaseHelper(Context context) {
    super(context, DATABASE_NAME, null, 1);
    SQLiteDatabase db = this.getWritableDatabase();
}

@Override
public void onCreate(SQLiteDatabase db)
{
    db.execSQL("create table" + DATABASE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)");

}

   @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        db.execSQL("DROP TABLE IF EXISTS "+ TABLE_NAME);
        onCreate(db);

    }
}
 
There's a syntax error in your table creation statement. Change this line

Code:
db.execSQL("create table" + DATABASE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)");

To (note the space after "create table ")

Code:
db.execSQL("create table " + TABLE_NAME + "(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)");
 
Its still not workong... :(


--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.egids.lklmanager, PID: 2739
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.egids.lklmanager/com.example.egids.lklmanager.MainActivity}: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
at com.example.egids.lklmanager.DatabaseHelper.onCreate(DatabaseHelper.java:40)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.egids.lklmanager.DatabaseHelper.<init>(DatabaseHelper.java:34)
at com.example.egids.lklmanager.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.
 
Its still not workong... :(


--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.egids.lklmanager, PID: 2739
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.egids.lklmanager/com.example.egids.lklmanager.MainActivity}: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
at com.example.egids.lklmanager.DatabaseHelper.onCreate(DatabaseHelper.java:40)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.egids.lklmanager.DatabaseHelper.<init>(DatabaseHelper.java:34)
at com.example.egids.lklmanager.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.
You also need a space between the table name and the next part of the SQL query
 
Its still not workong... :(


--------- beginning of crash
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.egids.lklmanager, PID: 2739
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.egids.lklmanager/com.example.egids.lklmanager.MainActivity}: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: android.database.sqlite.SQLiteException: near "Kaunas": syntax error (code 1): , while compiling: create table Zalgiris Kaunas(ID INTEGER PRIMARY KEY AUTOINCREMENT, NAME TEXT, LASTNAME TEXT, AGE INTEGER, BIRTHDATE INTEGER, HEIGHT INTEGER, WEIGHT INTEGER, SKILL_LVL INTEGER, POSITION_FIRST TEXT, POSITION_SECOND TEXT)
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:889)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:500)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:31)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1677)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1608)
at com.example.egids.lklmanager.DatabaseHelper.onCreate(DatabaseHelper.java:40)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:251)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:163)
at com.example.egids.lklmanager.DatabaseHelper.<init>(DatabaseHelper.java:34)
at com.example.egids.lklmanager.MainActivity.onCreate(MainActivity.java:17)
at android.app.Activity.performCreate(Activity.java:6662)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Application terminated.
I.e. ("create table " + TABLE_NAME + " (

See the space after " but neither before (

Create table "foo" (

Not

Create table"foo"(
 
Back
Top Bottom