Code for Insertion:
/**
* called to insert data in table.
* */
public void insertFavCinema(int cinemaId, String name, String url,
String lat_long, String numberOfMovies, String phone) {
// Log.d(TAG, "Inserting fav cinema with cinema =" + name);
ContentValues values = new ContentValues();
Long rowId = null;
try {
db = openHelper.getWritableDatabase();
values.put("cinemaid", cinemaId);
if (name != null) {
values.put("name", name);
}
if (url != null) {
values.put("url", url);
}
if (lat_long != null) {
values.put("ll", lat_long);
}
if (numberOfMovies != null) {
values.put("numberOfMovies", numberOfMovies);
}
if (phone != null) {
values.put("phone", phone);
}
rowId = db.insert(TABLE_NAME, null, values);
} catch (Exception e) {
if (db.isOpen()) {
db.close();
}
}
if (rowId != -1) {
Log.d("Insert Method executed successfully", "");
} else {
Log.d("Data is not Inserted", "");
}
if (db.isOpen()) {
db.close();
}
}
Deletion :
/**
* Method to delete row from Favourites cinema List
*
* @param cinemaId
*/
public void deleteCinema(int cinemaId) {
db = openHelper.getWritableDatabase();
db.delete(TABLE_NAME, "cinemaid=" + cinemaId, null);
// Log.d("Inside delete cinema method.", "");
if (db.isOpen()) {
db.close();
}
}
On Aug 10, 11:31 am, Jitendra Nandiya <[email protected]>
wrote:
> Plz help me for my problem.....
> How Insertion,deletion & updation on SQL database in android is
> solved....?????
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en