In the process of linking Android SQlite, there was no grammar error, but it was forced to stop when I executed it I'm posting a question. Where's the problem?
DBhelper class
package com.example.myapplication;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class dbHelper extends SQLiteOpenHelper {
public dbHelper(Context context)
{
super(context, "GoSchoolDB", null, 1);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE GoSchoolDB (_id INTEGER PRIMARY KEY AUTOINCREMENT name TEXT tel TEXT);");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS GoSchoolDB");
onCreate(db);
}
}
MainActivity class
package com.example.myapplication;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
public class MainActivity extends AppCompatActivity {
dbHelper helper;
SQLiteDatabase db;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
helper = new dbHelper(this);
try{
db = helper.getWritableDatabase();
}catch (SQLiteException e)
{
db = helper.getReadableDatabase();
}
}
}
android sqlite
There's no comma in the "CREATE TABLE"~
© 2024 OneMinuteCode. All rights reserved.