I created database for inserting and updating values which are came from server this is ok. My problem is when updating my values if new values are came from server how can i mange both inserting and updating at a time. Please provide any suggestions to me. Thanks in Advance.
Asked
Active
Viewed 1,283 times
1
-
@Satishreddy u have to just update ur raw using query.first u have to call insert and then update method. – TheFlash Aug 05 '13 at 11:53
-
try `insertWithOnConflict` with `CONFLICT_REPLACE` flag – Boris Mocialov Aug 05 '13 at 11:58
3 Answers
0
Your question is pretty broad however, the values that are coming across from the server need to have a unquie identifier if you are wanting to overwrite them later with new values. If you get values coming to you and want to overwrite them later you need to know which ones to overwrite hence you could go straight there with a unique identifier.

ObieMD5
- 2,684
- 1
- 16
- 26
0
This is code for inserting values into database
public void insert(ContentValues values)
{
DataBase_Object.insert(TABLE_Name , null, values);
}
This is code for Update values into database
public void putQty(ContentValues values)
{
DataBase_Object.update(TABLE_Name, values ,
Where Condition, null);
}
Hope it helps.

Sanket Shah
- 4,352
- 3
- 21
- 41
0
I believe that you are asking how to insert new rows or overwrite your existing rows in one step. While that is possible in a single raw SQL as discussed in this answer, I found that it easier to do this in two steps in Android and preserving values in all your columns.
I posted my answer here.

Community
- 1
- 1

theczechsensation
- 4,215
- 2
- 24
- 25