编译应用程序时LogCat中的错误应用程序、错误、LogCat

由网友(自拍界扛把子)分享简介:当我编译应用程序这些错误显示:When i compile the app these errors show:sqlite returned: error code = 1, msg = table mensagens already existsFailure 1 (table mensagens already...

当我编译应用程序这些错误显示:

When i compile the app these errors show:

   sqlite returned: error code = 1, msg = table mensagens already exists
   Failure 1 (table mensagens already exists) on 0x240328 when preparing 'create table mensagens(mensagemsalva varchar(250),mensagemenviada varchar(250))'.
   sqlite returned: error code = 1, msg = table contatos already exists
   Failure 1 (table contatos already exists) on 0x240328 when preparing 'create table contatos(nome varchar(50),telefone varchar(20))'.

我的Main.java有这个code这是为了创建数据库及其表:

My Main.java has this code which is meant to create the database and its tables:

  onCreate(..){
   ...
  db = openOrCreateDatabase("banco.db", Context.MODE_WORLD_WRITEABLE, null);
    ...
    VerificaDados();
  }

    private void VerificaDados() {
    // TODO Auto-generated method stub

    try {
        //cria uma TABLE de nome MENSAGENS
        db.execSQL("create table mensagens(mensagemsalva varchar(250),mensagemenviada varchar(250))");
        //ShowMessage("Banco","Criou a tabela de mensagens");
    }
    catch (Exception e) {

        }
    try{
        //cria uma TABLE de nome CONTATOS
        db.execSQL("create table contatos(nome varchar(50),telefone varchar(20))");
        //ShowMessage("Banco","Criou a tabela de contatos");
    }catch (Exception a){

    }

}

IDK的也可以是什么,因为我只是在LogCat中运行应用程序和BAM,错误。

idk what it can be because i just run the app and BAM, errors in LogCat.

推荐答案

看一看athe中的 SQLiteOpenHelper API文档。

Have a look athe the SQLiteOpenHelper API Docs.

本类需要如果存在打开数据库的照顾,创建  它,如果它不和将其升级是必要的。

this class takes care of opening the database if it exists, creating it if it does not, and upgrading it as necessary.

您应该尝试的onCreate()的onUpdate()

阅读全文

相关推荐

最新文章