Long []无法转换为String []

时间:2015-12-08 03:54:15

标签: android string sqlite long-integer

我想更新我的SQLite数据,但我收到incompatible types: Long[] cannot be converted to String[]错误。

public void Update(long id, String name, String weather, String date, String status )
    {
        ContentValues cv=new ContentValues();
        Long [] args={id};
        cv.put(MyDatabaseHelper.Name, name);
        cv.put(MyDatabaseHelper.Weather, weather);
        cv.put(MyDatabaseHelper.Date, date);
        cv.put(MyDatabaseHelper.Status, status);
        database.update(MyDatabaseHelper.TABLE_INFO, cv, MyDatabaseHelper.ID + "= ?",args);}

有人能帮助我吗?感谢

1 个答案:

答案 0 :(得分:1)

也许你可以这样做:

public void Update(long id, String name, String weather, String date, String status )
    {
        ContentValues cv=new ContentValues();
        cv.put(MyDatabaseHelper.Name, name);
        cv.put(MyDatabaseHelper.Weather, weather);
        cv.put(MyDatabaseHelper.Date, date);
        cv.put(MyDatabaseHelper.Status, status);
        database.update(MyDatabaseHelper.TABLE_INFO, cv, MyDatabaseHelper.ID + "=" + id,null);
    }

OR

将您的ID转换为字符串:

public void Update(long id, String name, String weather, String date, String status )
    {
        ContentValues cv=new ContentValues();
        String [] args={String.valueOf(id)};
        cv.put(MyDatabaseHelper.Name, name);
        cv.put(MyDatabaseHelper.Weather, weather);
        cv.put(MyDatabaseHelper.Date, date);
        cv.put(MyDatabaseHelper.Status, status);
        database.update(MyDatabaseHelper.TABLE_INFO, cv, MyDatabaseHelper.ID + "= ?",args);
    }