-1

すみません、初心者で、

あるページにデータを保存し、別のページにフェッチする単純なアプリがあります。データをフェッチしようとすると、そのような列が見つからないというエラーが表示され続けます。助けてください

これは、データを入力するコード、EnterDetails.java です。

            @Override
        public void onClick(View arg0) {
            EditText holdersala = (EditText) findViewById(R.id.rawsalary);
            EditText wantspercentage = (EditText) findViewById(R.id.wantspercent);
            EditText needspercentage = (EditText) findViewById(R.id.needspercent);

            String holdersalary = holdersala.getText().toString();
            final int salary = Integer.parseInt(holdersalary);

            String holderwantsp = wantspercentage.getText().toString();
            final int wantsp = Integer.parseInt(holderwantsp);

            String holderneedsp = needspercentage.getText().toString();
            final int needsp = Integer.parseInt(holderneedsp);

            if(wantsp + needsp <= 100){

                DatabaseAdapter databaseAdapter = new DatabaseAdapter(getApplicationContext());
                databaseAdapter.open();
                databaseAdapter.createRecordS(salary);
                databaseAdapter.createRecordW(wantsp);
                databaseAdapter.createRecordN(needsp);
                databaseAdapter.close();

                startActivity(new Intent(EnterDetails.this, Summary.class));
            } else {
            } 

            Toast toast = Toast.makeText(EnterDetails.this, "incorrect data", 5000);
            toast.setGravity(Gravity.CENTER, 0, 0);
            toast.show(); 
        }
    });

データを取得するコード

        TextView bn = (TextView) findViewById(R.id.budget_need);


     DatabaseAdapter databaseAdapter = new DatabaseAdapter(getApplicationContext());
        databaseAdapter.open();
        bn.setText(databaseAdapter.fetchRecordS(1));
        databaseAdapter.close();

私のdatabaseAdapter.javaからのコード

  public class DatabaseAdapter {

private Context context;
private SQLiteDatabase database;
private DatabaseOpenHelper dbHelper;

public DatabaseAdapter(Context context) {
    this.context = context;
}
public DatabaseAdapter open() throws SQLException {
    dbHelper = new DatabaseOpenHelper(context);
    database = dbHelper.getWritableDatabase();
    return this;
}

public void close() {
    dbHelper.close();
}
public long createRecordS(int interger) {
    ContentValues contentValue = new ContentValues();        
    contentValue.put("salafig", interger);            
    return database.insert("maindata", null, contentValue);
}
public long createRecordN(int interger) {
    ContentValues contentValue = new ContentValues();        
    contentValue.put("needsper", interger);            
    return database.insert("maindata", null, contentValue);
}
public long createRecordW(int interger) {
    ContentValues contentValue = new ContentValues();        
    contentValue.put("wantsper", interger);            
    return database.insert("maindata", null, contentValue);
}
public int fetchRecordS(long rowId) throws SQLException {
    Cursor mCursor = database.query(true, "maindata", new String[] { "salafig",
            "needsper", "wantsper" }, "salafig"+ rowId, null, null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
        return (mCursor.getInt(1));
    }
    return (Integer) null;
}
public int fetchRecordW(long rowId) throws SQLException {
    Cursor mCursor = database.query(true, "maindata", new String[] { "salafig",
            "needsper", "wantsper" }, "wantsper"+ rowId, null, null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
        return (mCursor.getInt(1));
    }
    return (Integer) null;
}public int fetchRecordN(long rowId) throws SQLException {
    Cursor mCursor = database.query(true, "maindata", new String[] { "salafig",
            "needsper", "wantsper" }, "needsper"+ rowId, null, null, null, null, null);
    if (mCursor != null) {
        mCursor.moveToFirst();
        return (mCursor.getInt(1));
    }

事前に何か助けがあれば、それが理にかなっていることを願っています。

4

1 に答える 1