'不幸的是,应用程序已停止工作'错误问题 [英] 'unfortunately,apps has stopped working' error problem

查看:109
本文介绍了'不幸的是,应用程序已停止工作'错误问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个java类文件,即a。 listmasteritems b。 Mydbhandler。

在一项活动中,我使用了edittext和一个按钮。在按钮上单击设备,我打算将文本发送到数据库。按钮点击(在设备中)我收到错误说明

'不幸的是,当我包括该行时,tommy已停止工作

'dbHandler.addNewAccountName(name);' 。



以下是我的代码:



I have two java class files namely a. listmasteritems b. Mydbhandler.
In an activity I use an edittext and a button. On button click in the device, I intend to send the text to the database. I get an error on button click (in device) stating
'Unfortunately,tommy has stopped working' when I include the line
'dbHandler.addNewAccountName(name);'.

Hereunder is my code:

public void onBtnIncludeClick( View v)
    {
        listmasteritems name=new listmasteritems(editText.getText().toString());
        dbHandler.addNewAccountName(name);

    }









在Mydbhandler :





//向数据库添加新行

public void addNewAccountName(listmasteritems name)

{

ContentValues values = new ContentValues();

values.put(COLUMN_NAME,name.get_accountname());

SQLiteDatabase db = getWritableDatabase();

db.insert(TABLE_ACCOUNTHEADS,null,values);

db.close();

}





In Mydbhandler:


//add new row to the database
public void addNewAccountName(listmasteritems name)
{
ContentValues values= new ContentValues();
values.put(COLUMN_NAME,name.get_accountname());
SQLiteDatabase db=getWritableDatabase();
db.insert(TABLE_ACCOUNTHEADS,null,values);
db.close();
}

推荐答案

导致错误的原因有很多种。



There are many possible reasons why this caused an error.



  1. 未建立连接
  2. 价值错误





..等等。实际问题出在您的控制台中;或者用于Logcat中的Android开发。你应该看看为什么引发异常。然后,解决该异常的原因。



.. and so on. The actual problem is in your Console; or for Android development in Logcat. You should see for why the exception got raised. Then, solve that exception's cause.


这篇关于'不幸的是,应用程序已停止工作'错误问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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