2011-08-02 37 views
0

如何在DBAdapter中插入查询?这是我的SQL插入查询。它在运行时创建字段&值。然后需要执行。Android sqlite动态插入查询

这是我的代码:

public void insertTableRecord(String strTableName, String strToFields, String strValues){ 
    String Sql = "Insert into " + strTableName + "(" + strToFields + ") Values (" + strValues + ")"; 
    DBAdapter dbAdapter = DBAdapter.getDBAdapterInstance(DownlaodTableActivity.this); 
    dbAdapter.openDataBase(); 

    ContentValues initialValues = new ContentValues(); 
    //initialValues.put("how to give", ??how to give); 
    long n = dbAdapter.insertRecordsInDB(strTableName, null, initialValues); 
} 

请告诉我如何做到这一点的一部分。

请帮助我..

在此先感谢..

回答

1

尝试initialValues.put(strToFields,strValue);

+0

克里特!!!谢谢它的工作正常 – Piraba

+0

不客气 – Rasel