我试图将字符串从Mainactivity传递给databaseadapter类,以在string中用string(由int而不是sqlite指定)更新第一列,但意识到仅与db.update()一起使用。a)在mainactivity中,对于intInteger jacky = 78;myDb.updateK(jacky);b)在mainactivity中,对于StringString jackie = "jacko";myDb.updateK(jackie);在数据库适配器中String cup = "_id = 1";//since jack doesn't have to be jacky or jackie, and can be marypublic void updateK(int mary){ContentValues tree = new ContentValues();tree.put("columnone", mary);db.update("TableOne", tree, cup, null);}在上述情况下,仅在使用int的情况下a)有效,而在使用字符串jacko的情况b)下则无效。有没有一种方法可以解决此问题,并将字符串从int传递到mainactivity?如您所知,我是android的新手,非常感谢你们给我的任何指导。 (adsbygoogle = window.adsbygoogle || []).push({}); 最佳答案 a)在mainactivity中,对于intInteger jacky = 78;myDb.updateK(jacky);b)在mainactivity中,对于StringString jackie = "jacko";myDb.updateK(jackie);在数据库适配器中String cup = "_id = 1";//since jack doesn't have to be jacky or jackie, and can be marypublic void updateK(Object mary){ContentValues tree = new ContentValues();tree.put("columnone", mary);db.update("TableOne", tree, cup, null);}注意:您的树还应该接受对象 (adsbygoogle = window.adsbygoogle || []).push({});
10-08 11:35