To enter in sqlite currently I have to follow these steps:
- Create contentValues i.e.
ContentValues contentValues = new ContentValues(); - Put the call_name and value
- Finally call
sqLiteDatabase.insert(DATABASE_NAME,null,contentValues)
The problem is only in step 2, we have manually Columnnameand Columnvaluefor n number of times, assuming that I have n columns that need to be saved.
So, I wrote the following method, thinking that I can reuse it:
public void insert(Map tableMap){
ContentValues contentValues = new ContentValues();
Iterator tableMapIterator = tableMap.entrySet().iterator();
while(tableMapIterator.hasNext()){
Map.Entry mapEntry = (Map.Entry)tableMapIterator.next();
contentValues.put((String)mapEntry.getKey(), mapEntry.getValue());
}
sqLiteDatabase.insert(DATABASE_NAME,null,contentValues)
}
But the problem is that when I call mapEntry.getValue(), the return type is Object, for which contentValues.putit is not defined.
So, can anyone tell me some workaround so that I can effectively use the above approach for data entry.
. , SQLITE.