Skip to content Skip to sidebar Skip to footer

Android Sqlite Added Extra Columns Now Can't View Data

I had this previously working with only two of the parameters, 'Weight' and Waist', I then proceeded to add extra columns to the database, resulting in the application force closin

Solution 1:

The problem is: You are not making any entries to the database. Make sure that "tvDBInfo" is a text view. If it is text view then only post the code for "view_stats".

I tried the following code and it is working :

publicclassDBViewextendsActivity {


    @OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.view_stats);
        TextViewtv= (TextView) findViewById(R.id.tvDBInfo);
        StatsdbInfo=newStats(this);
        dbInfo.open();
        dbInfo.createEntry("weight", "waist", "chest", "legs", "arms");
        Stringdata= dbInfo.getData();
        dbInfo.close();
        if (!TextUtils.isEmpty(data)) {
            tv.setText(data);
        }
    }
}

The problem is with your layout. You have nested text view within a text view which is not feasible. Change the last three text view inside the table row i.e

<TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Chest" ><TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Legs" /><TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Arms" /></TextView>

to this

<TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Chest" /><TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Legs" /><TextViewandroid:layout_width="wrap_content"android:layout_height="fill_parent"android:text="Arms" />

and everything should work.

Post a Comment for "Android Sqlite Added Extra Columns Now Can't View Data"