tags:

views:

36

answers:

2

Hi, i am an android application developer. I am developing an application which requires of me to use Sqlite database. I have implemented fetching the data, but i am facing problems when i try to insert data into the Sqlite database. The problem that i am having is that the new data i enter is not fetched, i.e nothing is new is being entered into the database. Please do help me......

this is the method i wrote in Data.java...

myDataBase is an object of SQLiteDatabase...

public void insertTitle(String Recipe)
{
ContentValues initialValues = new ContentValues();
initialValues.put(COLUMN_NAME,value);
myDataBase.insert(ZRECIPE, null, initialValues);
}

and i create an object "d" of it in Add.java, where i call the "insertTitle()" method...

But nothing is inserted.

Thanks

A: 

You forgot to commit the transaction.

Aaron Gallagher
Hi, but how to commit the transcaction..?
Jaymin
A: 

Try it this way. You need first start transaction, then mark it as successful and end.

   try {  
       myDataBase.beginTransaction();
       myDataBase.insert(ZRECIPE, null, initialValues);
       myDataBase.setTransactionSuccessful();
       } 
   finally {
       myDataBase.endTransaction();
       }
Konstantin Burov