Hi, I'm learning android development for a month now and I'm trying to 
develop a little project.

I've got a small problem, I want to insert a record into my database from a 
button click, here's some code.

In my DBAdapter class, I've got this method:


    public long insertRecordCategory(String nome) {
        ContentValues initialValues = new ContentValues();
        initialValues.put(KEY_NOME, nome);

        return db.insert(TABELA_CATEGORIA, null, initialValues);

    }

It's the method that allows (or should allow) me to insert a single record 
into a table which has only two fields, (id and name).

Then, on the class which extends the activity in which I want to have my 
button and edit text field for insertion of the new 'category', I've got 
this:

        but1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                
                String new_cat = editCategory.getText().toString();
                DBAdapter dbadap = DBAdapter.getInstance(ctx);
                dbadap.getWritableDatabase();
                Cursor c = dbadap.insertRecordCategoria(new_cat);
                        
            }
        
        });

The error I get is on the last line -------> Cursor c = 
dbadap.insertRecordCategoria(new_cat);

Can someone help me figure out what the problem is?


Thanks, Chiapa

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to