编译应用程序时LogCat中的错误 [英] LogCat errors when Compiling App

查看:123
本文介绍了编译应用程序时LogCat中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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()

这篇关于编译应用程序时LogCat中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆