Android 触发原始查询时出错

Android 触发原始查询时出错,android,illegalstateexception,Android,Illegalstateexception,我在以下语句中说“IllegalStateException:数据库未打开”时出错: Cursor cursor = database.rawQuery("select rec_field_id, field_value from records_fields_data where cat_field_id = "+get_cat_field_id(category_fields_array_list.get(i))+" AND rec_id = "+rec_id+";", null); 这是

我在以下语句中说“IllegalStateException:数据库未打开”时出错:

Cursor cursor = database.rawQuery("select rec_field_id, field_value from records_fields_data where cat_field_id = "+get_cat_field_id(category_fields_array_list.get(i))+" AND rec_id = "+rec_id+";", null);
这是我的完整java代码:

  package com.walletapp;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.ContentValues;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

public class AddRecords extends Activity {

    Spinner category_spinner;
    SQLiteDatabase database;
    ArrayList<String> category_spinner_array_list, category_fields_array_list;
    int cat_id;
    int rec_id;
    String[] tags;
    ArrayList<String> tmp_category_fields_array_list;
    ArrayList<String> tags_list;
    private ArrayList<String> selectedTags;
    ArrayList<EditText> edit_text_array_list;
    EditText et_tags;
    int tag_editText_id;
    String cat_name;
    String record_data;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add_records);

        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

        Intent intent = getIntent();
        rec_id = intent.getIntExtra("rec_id", 0);
        record_data = intent.getStringExtra("record_data");
        cat_name = intent.getStringExtra("cat_name");

        category_spinner = (Spinner) findViewById(R.id.spinnerAddRecords);
        build_spinner_list();
        database.close();

        if (rec_id != 0) {
            category_spinner.setSelection(category_spinner_array_list
                    .indexOf(cat_name));
            // generateUI(cat_name);
            category_spinner.setEnabled(false);
        }

        category_spinner
                .setOnItemSelectedListener(new OnItemSelectedListener() {

                    @Override
                    public void onItemSelected(AdapterView<?> arg0, View arg1,
                            int arg2, long arg3) {

                        generateUI(arg0.getItemAtPosition(arg2) + "");
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> arg0) {

                    }
                });
    }

    protected void generateUI(String string) {

        Log.i("generate UI string passed is : ", string);

        LinearLayout linearLayout_inner = (LinearLayout) findViewById(R.id.linearLayoutAddRecordsScrollViewInner);

        if (string.equals("Category")) {

            linearLayout_inner.removeAllViews();
            Toast.makeText(getBaseContext(),
                    "Select the category to proceed further.",
                    Toast.LENGTH_SHORT).show();
        } else {

            linearLayout_inner.removeAllViewsInLayout();

            tmp_category_fields_array_list = new ArrayList<String>();

            cat_id = getId(string);
            tmp_category_fields_array_list = get_field_names(cat_id);

            category_fields_array_list = new ArrayList<String>();
            category_fields_array_list = get_sorted_fields(tmp_category_fields_array_list);

            edit_text_array_list = new ArrayList<EditText>();

            if (rec_id == 0) {
                for (String s : category_fields_array_list) {
                    TextView tv = new TextView(this);
                    tv.setText(s);
                    linearLayout_inner.addView(tv);

                    EditText et = new EditText(this);
                    et.setHint(s);
                    et.setTag(new Tag(get_cat_field_id(s), s));
                    edit_text_array_list.add(et);

                    linearLayout_inner.addView(et);

                    if (s.equals("Tags")) {
                        tag_editText_id = et.getId();
                        et_tags = et;
                        et.setFocusable(false);
                        et.setFocusableInTouchMode(false);
                        et.setOnClickListener(new OnClickListener() {

                            @Override
                            public void onClick(View v) {

                                showSelectTagsDialog();
                            }
                        });
                    }
                }
            } else {
                Log.i("database is open.", database.isOpen() + "");
                // for(String s : category_fields_array_list)
                for (int i = 0; i < category_fields_array_list.size(); i++) {
                    TextView tv = new TextView(this);
                    tv.setText(category_fields_array_list.get(i));
                    linearLayout_inner.addView(tv);

                    ArrayList<Integer> al_rec_field_id = new ArrayList<Integer>();
                    ArrayList<String> al_field_value = new ArrayList<String>();

                    Cursor cursor = database
                            .rawQuery(
                                    "select rec_field_id, field_value from records_fields_data where cat_field_id = "
                                            + get_cat_field_id(category_fields_array_list
                                                    .get(i))
                                            + " AND rec_id = "
                                            + rec_id + ";", null);
                    while (cursor.moveToNext()) {
                        al_rec_field_id.add(cursor.getInt(0));
                        al_field_value.add(cursor.getString(1));
                    }
                    cursor.close();

                    // ----------------------------------------------------------------------------------------------

                    EditText et = new EditText(this);
                    // et.setHint(category_fields_array_list.get(i));
                    et.setText(al_field_value.get(i));
                    // Tag(int tmp_rec_field_id, int tmp_rec_id, int
                    // tmp_cat_field_id)
                    et.setTag(new Tag(al_rec_field_id.get(i), rec_id,
                            get_cat_field_id(category_fields_array_list.get(i))));
                    edit_text_array_list.add(et);

                    linearLayout_inner.addView(et);

                    if (category_fields_array_list.get(i).equals("Tags")) {
                        tag_editText_id = et.getId();
                        et_tags = et;
                        et.setFocusable(false);
                        et.setFocusableInTouchMode(false);
                        et.setOnClickListener(new OnClickListener() {

                            @Override
                            public void onClick(View v) {

                                showSelectTagsDialog();
                            }
                        });
                    }
                }
            }

            Button btn = new Button(this);
            btn.setText("Save");
            btn.setOnClickListener(new OnClickListener() {

                @Override
                public void onClick(View v) {

                    loadDatabase();
                    ContentValues values = new ContentValues();
                    String currentDate = new SimpleDateFormat("yyyy/MM/dd")
                            .format(Calendar.getInstance().getTime());
                    Tag tag = null;
                    int rec_id = 0;

                    for (int i = 0; i < edit_text_array_list.size(); i++) {
                        if (i == 0) {
                            // --------------first insert into records_data
                            // table------------

                            values.put("cat_id", cat_id);
                            values.put("tag_id", "0");
                            values.put("is_favourite", "0");
                            values.put("rec_name", edit_text_array_list.get(i)
                                    .getText() + "");
                            values.put("is_delete", "0");
                            values.put("create_date", currentDate);
                            values.put("update_date", "0");

                            database.insert("records_data", null, values);
                            values.clear();

                            // -------------then fetch the rec_id for previously
                            // entered record----------

                            Cursor cursor = database
                                    .query("records_data",
                                            new String[] { "rec_id" },
                                            "rec_name=?",
                                            new String[] { edit_text_array_list
                                                    .get(i).getText() + "" },
                                            null, null, null);
                            while (cursor.moveToNext())
                                rec_id = cursor.getInt(0);
                            cursor.close();

                            // -------------use this rec_id for inserting record
                            // into records_fields_data------------

                            values.put("rec_id", rec_id);

                            // ---------get cat_field_id----------

                            tag = (Tag) edit_text_array_list.get(i).getTag();

                            values.put("cat_field_id", tag.get_cat_field_id());
                            values.put("field_value",
                                    edit_text_array_list.get(i).getText() + "");
                            values.put("is_delete", "0");
                            values.put("create_date", currentDate);
                            values.put("update_date", "0");

                            database.insert("records_fields_data", null, values);
                            values.clear();
                        } else if (i < edit_text_array_list.size() - 1) {

                            values.put("rec_id", rec_id);
                            tag = (Tag) edit_text_array_list.get(i).getTag();

                            values.put("cat_field_id", tag.get_cat_field_id());
                            values.put("field_value",
                                    edit_text_array_list.get(i).getText() + "");
                            values.put("is_delete", "0");
                            values.put("create_date", currentDate);
                            values.put("update_date", "0");

                            database.insert("records_fields_data", null, values);
                            values.clear();
                        } else {
                            for (String s : selectedTags) {
                                int tag_id = get_tag_id(s);

                                values.put("rec_id", rec_id);
                                values.put("tag_id", tag_id);

                                database.insert("record_tag_relation", null,
                                        values);
                                values.clear();
                            }
                        }
                    }

                    if (database.isOpen())
                        database.close();

                    finish();
                    startActivity(new Intent(AddRecords.this, AllRecords.class));
                }
            });
            linearLayout_inner.addView(btn);
        }
    }

    protected int get_tag_id(String s) {

        int tag_id = 0;
        Cursor cursor = database.query("tags", new String[] { "tag_id" },
                "tag_name=?", new String[] { s }, null, null, null);
        while (cursor.moveToNext()) {
            tag_id = cursor.getInt(0);
        }
        return tag_id;
    }

    protected void showSelectTagsDialog() {

        build_tags_list();
        selectedTags = new ArrayList<String>();

        boolean[] checkedTags = new boolean[tags.length];
        int count = tags.length;

        for (int i = 0; i < count; i++)
            checkedTags[i] = selectedTags.contains(tags[i]);

        DialogInterface.OnMultiChoiceClickListener tagsDialogListener = new DialogInterface.OnMultiChoiceClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which,
                    boolean isChecked) {
                if (isChecked)
                    selectedTags.add(tags[which]);
                else
                    selectedTags.remove(tags[which]);

                onChangeSelectedTags();
            }
        };

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Select Tag(s)");
        builder.setMultiChoiceItems(tags, checkedTags, tagsDialogListener);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.dismiss();
            }
        });

        AlertDialog dialog = builder.create();
        dialog.show();
    }

    protected void onChangeSelectedTags() {

        StringBuilder stringBuilder = new StringBuilder();

        int count = 0;
        for (CharSequence tag : selectedTags) {
            count = count + 1;
            stringBuilder.append(tag);
            if (count < selectedTags.size())
                stringBuilder.append(",");
        }

        for (EditText e : edit_text_array_list) {

            if (e == et_tags) {
                e.setText(stringBuilder.toString());
                break;
            }
        }
    }

    private void build_tags_list() {

        loadDatabase();

        tags_list = new ArrayList<String>();
        Cursor cursor = database.query("tags", new String[] { "tag_name" },
                null, null, null, null, null);
        while (cursor.moveToNext())
            tags_list.add(cursor.getString(0));
        cursor.close();
        database.close();

        tags = tags_list.toArray(new String[tags_list.size()]);
    }

    private int get_cat_field_id(String s) {

        loadDatabase();

        int tmp_cat_field_id = 0;
        Cursor cursor = database.query("category_fields",
                new String[] { "cat_field_id" }, "field_name=?",
                new String[] { s }, null, null, null);
        while (cursor.moveToNext())
            tmp_cat_field_id = cursor.getInt(0);
        cursor.close();
        database.close();

        return tmp_cat_field_id;
    }

    private ArrayList<String> get_sorted_fields(
            ArrayList<String> tmp_category_fields_array_list2) {

        int count = 0;
        ArrayList<String> al_tmp = new ArrayList<String>();
        for (String s : tmp_category_fields_array_list2) {
            if (s.equals("Description")) {
                if (al_tmp.contains(s)) {
                    // ----do nothing
                } else {
                    al_tmp.add(s);
                }
            } else if (s.equals("Notes")) {
                continue;
            } else if (s.equals("Tags")) {
                continue;
            } else {
                if (al_tmp.contains(s)) {
                    // ----do nothing
                } else {
                    al_tmp.add(s);
                }
            }
            count++;
            if (count == tmp_category_fields_array_list.size() - 2) {
                al_tmp.add("Notes");
                al_tmp.add("Tags");
            }
        }
        return al_tmp;
    }

    private ArrayList<String> get_field_names(int cat_id) {

        loadDatabase();

        ArrayList<String> tmp_cat_field_array_list = new ArrayList<String>();

        Cursor cursor = database.query("category_fields",
                new String[] { "field_name" }, "cat_id=?",
                new String[] { cat_id + "" }, null, null, null);
        while (cursor.moveToNext())
            tmp_cat_field_array_list.add(cursor.getString(0));
        cursor.close();

        return tmp_cat_field_array_list;
    }

    protected int getId(String string) {

        loadDatabase();

        int tmp_cat_id = 0;
        Cursor cursor = database.query("category", new String[] { "cat_id" },
                "cat_description=?", new String[] { string }, null, null, null);
        while (cursor.moveToNext())
            tmp_cat_id = cursor.getInt(0);
        cursor.close();
        database.close();

        return tmp_cat_id;
    }

    private void build_spinner_list() {

        loadDatabase();

        category_spinner_array_list = new ArrayList<String>();
        category_spinner_array_list.add("Category");
        Cursor cursor = database.query("category",
                new String[] { "cat_description" }, null, null, null, null,
                null);
        while (cursor.moveToNext())
            category_spinner_array_list.add(cursor.getString(0));
        cursor.close();
        ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
                android.R.layout.simple_list_item_1,
                category_spinner_array_list);
        dataAdapter
                .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        category_spinner.setAdapter(dataAdapter);
    }

    private void loadDatabase() {

        database = openOrCreateDatabase("WalletAppDatabase.db",
                SQLiteDatabase.OPEN_READWRITE, null);
    }

    class Tag {
        int cat_field_id;
        String cat_field_name;
        int rec_field_id;
        int rec_id;

        Tag(int id, String name) {
            cat_field_id = id;
            cat_field_name = name;
        }

        Tag(int tmp_rec_field_id, int tmp_rec_id, int tmp_cat_field_id) {
            cat_field_id = tmp_cat_field_id;
            rec_id = tmp_rec_id;
            rec_field_id = tmp_rec_field_id;
        }

        int get_cat_field_id() {
            return cat_field_id;
        }

        String get_cat_field_name() {
            return cat_field_name;
        }

        int get_rec_field_id() {
            return rec_field_id;
        }

        int get_rec_id() {
            return rec_id;
        }
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

            if (database.isOpen())
                database.close();
            finish();

            if (rec_id == 0)
                startActivity(new Intent(AddRecords.this, AllRecords.class));
            else
                startActivity(new Intent(AddRecords.this,
                        RecordsDetailedView.class));
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }
}
package com.walletapp;
导入java.text.simpleDataFormat;
导入java.util.ArrayList;
导入java.util.Calendar;
导入android.app.Activity;
导入android.app.AlertDialog;
导入android.content.ContentValues;
导入android.content.DialogInterface;
导入android.content.Intent;
导入android.content.pm.ActivityInfo;
导入android.database.Cursor;
导入android.database.sqlite.SQLiteDatabase;
导入android.os.Bundle;
导入android.util.Log;
导入android.view.KeyEvent;
导入android.view.view;
导入android.view.view.OnClickListener;
导入android.widget.AdapterView;
导入android.widget.AdapterView.OnItemSelectedListener;
导入android.widget.ArrayAdapter;
导入android.widget.Button;
导入android.widget.EditText;
导入android.widget.LinearLayout;
导入android.widget.Spinner;
导入android.widget.TextView;
导入android.widget.Toast;
公共类AddRecords扩展活动{
微调器类别\u微调器;
SQLITE数据库;
ArrayList类别\微调器\数组\列表、类别\字段\数组\列表;
int cat_id;
int rec_id;
字符串[]标记;
ArrayList tmp_类别_字段_数组_列表;
ArrayList标签列表;
私有数组列表选择标记;
数组列表编辑\文本\数组\列表;
编辑文本等标签;
int tag_editText_id;
字符串cat_name;
字符串记录数据;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u add\u记录);
此.setRequestedOrientation(ActivityInfo.SCREEN\u ORIENTATION\u Graphic);
Intent=getIntent();
rec_id=intent.getIntExtra(“rec_id”,0);
record_data=intent.getStringExtra(“record_data”);
cat_name=intent.getStringExtra(“cat_name”);
category_微调器=(微调器)findViewById(R.id.spinnerAddressRecords);
构建微调器列表();
close()数据库;
如果(记录id!=0){
类别微调器。设置选择(类别微调器数组列表
.indexOf(类别名称);
//generateUI(类别名称);
类别_微调器。设置已启用(错误);
}
类别旋转器
.setOnItemSelectedListener(新的OnItemSelectedListener(){
@凌驾
已选择公共视图(AdapterView arg0、视图arg1、,
整数arg2,长arg3){
generateUI(arg0.getItemAtPosition(arg2)+“”);
}
@凌驾
未选择公共无效(AdapterView arg0){
}
});
}
受保护的无效生成器(字符串){
Log.i(“传递的生成UI字符串为:”,字符串);
LinearLayout LinearLayout_inner=(LinearLayout)findViewById(R.id.linearLayoutAddRecordsScrollViewInner);
if(string.equals(“类别”)){
linearLayout_inner.removeAllViews();
Toast.makeText(getBaseContext(),
“选择要继续的类别。”,
吐司。长度(短)。show();
}否则{
linearLayout_inner.移除布局()中的所有视图;
tmp_category_fields_array_list=new ArrayList();
cat_id=getId(字符串);
tmp\类别\字段\数组\列表=获取\字段\名称(cat\ id);
类别\字段\数组\列表=新数组列表();
类别字段数组列表=获取排序字段(tmp类别字段数组列表);
编辑_text_array_list=new ArrayList();
if(rec_id==0){
用于(字符串s:类别\字段\数组\列表){
TextView tv=新的TextView(此);
tv.setText(s);
线性布局\内部添加视图(电视);
EditText et=新的EditText(本);
et.setHint(s);
et.setTag(新标签(获取类别字段id));
编辑文本数组列表。添加(et);
线性布局\内部添加视图(et);
如果(s.equals(“标签”)){
tag_editText_id=et.getId();
et_标签=et;
et.setFocusable(假);
et.setFocusableInTouchMode(假);
et.setOnClickListener(新的OnClickListener(){
@凌驾
公共void onClick(视图v){
showSelectTagsDialog();
}
});
}
}
}否则{
Log.i(“数据库已打开”,database.isOpen()+”);
//用于(字符串s:类别\字段\数组\列表)
对于(int i=0;i03-28 19:52:09.060: W/KeyCharacterMap(19142): No keyboard for id 0
03-28 19:52:09.070: W/KeyCharacterMap(19142): Using default keymap: /system/usr/keychars/qwerty.kcm.bin
03-28 19:52:10.480: D/dalvikvm(19142): DexOpt: --- BEGIN 'ads34104.jar' (bootstrap=0) ---
03-28 19:52:10.650: D/dalvikvm(19142): DexOpt: --- END 'ads34104.jar' (success) ---
03-28 19:52:10.650: D/dalvikvm(19142): DEX prep '/data/data/com.walletapp/cache/ads34104.jar': unzip in 1ms, rewrite 167ms
03-28 19:52:10.770: D/dalvikvm(19142): GC_FOR_MALLOC freed 4534 objects / 295152 bytes in 86ms
03-28 19:52:11.140: E/ActivityThread(19142): Failed to find provider info for com.google.plus.platform
03-28 19:52:11.220: W/Ads(19142): loadAd called while the ad is already loading, so aborting.
03-28 19:52:11.350: I/Ads(19142): adRequestUrlHtml: <html><head><script src="http://media.admob.com/sdk-core-v40.js"></script><script>AFMA_getSdkConstants();AFMA_buildAdURL({"preqs":0,"session_id":"10699442437020247494","seq_num":"1","slotname":"a1512f50d8c3692","u_w":320,"msid":"com.walletapp","cap":"m,a","adtest":"on","js":"afma-sdk-a-v6.3.0","bas_off":0,"net":"ed","app_name":"1.android.com.walletapp","hl":"en","gnt":3,"carrier":"310260","u_audio":4,"kw":[],"u_sd":1,"simulator":1,"ms":"gHmei5U7VoADe6IEmAL5vLv6CPgwrxTqIxD3RsiiiukAljgNpKCC5wdhfTaJDFudJqp3jlSMt7IQh69rq2tF4dF7mb6cGUjuVtaNrXWv8IlY0shz8dI-iJtcdL05kuErjnIEkpkaKeilFUqY5qSSnF6siTb2kesTfzUM1VS76XkV7IE1q6yulBNFiXmECeZh349c0TjGh_3JdavLTR8MNSo8_c54G3_YkWKGEfhi3Q_lC4lkKWez-_l5_1moHM1MDDMxri5-2E348uKO75YfPB7CvBvFURAd7hD9ijU3Zq5G5dc72VPnnYdq5q819tb0NauVIQ450JDUN5mcbKGHAQ","isu":"B3EEABB8EE11C2BE770B684D95219ECB","format":"320x50_mb","oar":0,"ad_pos":{"height":0,"visible":0,"y":0,"x":0,"width":0},"u_h":480,"pt":1,"bas_on":0,"ptime":0});</script></head><body></body></html>
03-28 19:52:11.960: D/webviewglue(19142): nativeDestroy view: 0x293c08
03-28 19:52:11.970: D/dalvikvm(19142): GC_FOR_MALLOC freed 4152 objects / 371416 bytes in 218ms
03-28 19:52:15.091: W/webcore(19142): Can't get the viewWidth after the first layout
03-28 19:52:15.300: I/Ads(19142): Received ad url: <url: "http://googleads.g.doubleclick.net:80/mads/gma?preqs=0&session_id=10699442437020247494&seq_num=1&u_w=320&msid=com.walletapp&cap=m%2Ca&adtest=on&js=afma-sdk-a-v6.3.0&bas_off=0&net=ed&app_name=1.android.com.walletapp&hl=en&gnt=3&carrier=310260&u_audio=4&kw&u_sd=1&ms=gHmei5U7VoADe6IEmAL5vLv6CPgwrxTqIxD3RsiiiukAljgNpKCC5wdhfTaJDFudJqp3jlSMt7IQh69rq2tF4dF7mb6cGUjuVtaNrXWv8IlY0shz8dI-iJtcdL05kuErjnIEkpkaKeilFUqY5qSSnF6siTb2kesTfzUM1VS76XkV7IE1q6yulBNFiXmECeZh349c0TjGh_3JdavLTR8MNSo8_c54G3_YkWKGEfhi3Q_lC4lkKWez-_l5_1moHM1MDDMxri5-2E348uKO75YfPB7CvBvFURAd7hD9ijU3Zq5G5dc72VPnnYdq5q819tb0NauVIQ450JDUN5mcbKGHAQ&isu=B3EEABB8EE11C2BE770B684D95219ECB&format=320x50_mb&oar=0&u_h=480&bas_on=0&ptime=0&u_so=p&output=html&region=mobile_app&u_tz=330&client_sdk=1&ex=1&slotname=a14e8f77524dde8&kw_type=broad&gsb=3g&caps=interactiveVideo_th_autoplay_mediation_sdkAdmobApiForAds_di&jsv=46" type: "admob" afmaNotifyDt: "null" activationOverlayUrl: "null" useWebViewLoadUrl: "false">
03-28 19:52:15.300: I/Ads(19142): Request scenario: Online server request.
03-28 19:52:16.201: I/generate UI string passed is :(19142): web mail
03-28 19:52:16.300: I/database is open.(19142): true
03-28 19:52:16.390: D/AndroidRuntime(19142): Shutting down VM
03-28 19:52:16.390: W/dalvikvm(19142): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
03-28 19:52:16.480: D/dalvikvm(19142): GC_FOR_MALLOC freed 4094 objects / 277504 bytes in 77ms
03-28 19:52:16.491: W/SQLiteCompiledSql(19142): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: select rec_field_id, field_value from records_fields_data where cat_field_id = 8 AND rec_id = 1;
03-28 19:52:16.491: W/SQLiteCompiledSql(19142): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at com.walletapp.AddRecords.generateUI(AddRecords.java:158)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at com.walletapp.AddRecords$1.onItemSelected(AddRecords.java:77)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:864)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView.access$200(AdapterView.java:42)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:830)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.os.Handler.handleCallback(Handler.java:587)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.os.Looper.loop(Looper.java:123)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at java.lang.reflect.Method.invoke(Method.java:521)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-28 19:52:16.491: W/SQLiteCompiledSql(19142):     at dalvik.system.NativeStart.main(Native Method)
03-28 19:52:16.500: E/AndroidRuntime(19142): FATAL EXCEPTION: main
03-28 19:52:16.500: E/AndroidRuntime(19142): java.lang.IllegalStateException: database not open
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1333)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.database.sqlite.SQLiteDatabase.rawQuery(SQLiteDatabase.java:1315)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at com.walletapp.AddRecords.generateUI(AddRecords.java:158)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at com.walletapp.AddRecords$1.onItemSelected(AddRecords.java:77)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.widget.AdapterView.fireOnSelected(AdapterView.java:864)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.widget.AdapterView.access$200(AdapterView.java:42)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:830)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.os.Handler.handleCallback(Handler.java:587)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.os.Handler.dispatchMessage(Handler.java:92)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.os.Looper.loop(Looper.java:123)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at android.app.ActivityThread.main(ActivityThread.java:4627)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at java.lang.reflect.Method.invokeNative(Native Method)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at java.lang.reflect.Method.invoke(Method.java:521)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-28 19:52:16.500: E/AndroidRuntime(19142):    at dalvik.system.NativeStart.main(Native Method)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142): Releasing statement in a finalizer. Please ensure that you explicitly call close() on your cursor: SELECT field_name FROM category_fields WHERE cat_id=?
03-28 19:52:16.510: W/SQLiteCompiledSql(19142): android.database.sqlite.DatabaseObjectNotClosedException: Application did not close the cursor or database object that was opened here
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:62)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:80)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteQuery.<init>(SQLiteQuery.java:46)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:42)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1345)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1229)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1184)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at com.walletapp.AddRecords.get_field_names(AddRecords.java:427)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at com.walletapp.AddRecords.generateUI(AddRecords.java:107)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at com.walletapp.AddRecords$1.onItemSelected(AddRecords.java:77)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView.fireOnSelected(AdapterView.java:864)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView.access$200(AdapterView.java:42)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.widget.AdapterView$SelectionNotifier.run(AdapterView.java:830)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.os.Handler.handleCallback(Handler.java:587)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.os.Handler.dispatchMessage(Handler.java:92)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.os.Looper.loop(Looper.java:123)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at android.app.ActivityThread.main(ActivityThread.java:4627)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at java.lang.reflect.Method.invokeNative(Native Method)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at java.lang.reflect.Method.invoke(Method.java:521)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-28 19:52:16.510: W/SQLiteCompiledSql(19142):     at dalvik.system.NativeStart.main(Native Method)
03-28 19:52:16.550: