A
A
Anton @ Lyalin2017-06-24 17:28:59
Java
Anton @ Lyalin, 2017-06-24 17:28:59

Why doesn't the database creation start?

The database is not created, for this I even log.

class DataBase extends SQLiteOpenHelper{
    DataBase(Context context) {
        super(context, "myDB", null, 1);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        Log.d("myLog", "--- Create Data Base ---");
        db.execSQL("create table mytable ("
                + "id integer primary key autoincrement,"
                + "value text"
                + ");");
    }
    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}

public class MainActivity extends AppCompatActivity{

    final String tag = "myLog";
    DataBase dataBase;
    SQLiteDatabase sqLiteDatabase;
    ContentValues contentValues;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        Log.d(tag, "Создание Activity");
        dataBase = new DataBase(this);
        contentValues = new ContentValues();
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
goodTimes, 2017-06-24
@toxa_1995

Maybe you have already created it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question