我正在尝试将 a 转换int
为 aString
以便可以将String
值放入 SQLite 游标中。我尝试了多种语法和方法,但似乎没有一个对我有用。
尝试MangaItemDB()
转换任何Int
类型以及boolean
.
我已经浏览了几篇类似这样的文章,但没有一篇对我有用。
这是我的代码:
public class MangaItem {
private int _id;
private String mangaName;
private String mangaLink;
private static String mangaAlpha;
private static int mangaCount;
private static int alphaCount;
private boolean mangaComplete = false;
public MangaItem MangaItemDB(int id, String mangaName, String mangaLink, String mangaAlpha, String mangaCount, String alphaCount, String mangaComplete) {
MangaItem MangaItemDB = new MangaItem();
MangaItemDB._id = id;
MangaItemDB.mangaName = mangaName;
MangaItemDB.mangaLink = mangaLink;
MangaItemDB.mangaAlpha = mangaAlpha;
MangaItemDB.mangaCount = String.valueOf(int mangaCount);
MangaItemDB.alphaCount = Integer.toString(getAlphaCount());
MangaItemDB.mangaComplete = String.valueOf(getMangaComplete());
return MangaItemDB;
}
public void incrementMangaCount() {
mangaCount++;
}
public int getMangaCount() {
return mangaCount;
}
public void incrementAlphaCount() {
alphaCount++;
}
public int getAlphaCount() {
return alphaCount;
}
public boolean setMangaComplete(boolean mangaComplete) {
return true;
}
public boolean getMangaComplete() {
return mangaComplete;
}
/**
* @return the mangaName
*/
public String getMangaName() {
return mangaName;
}
/**
* @param mangaName the mangaName to set
*/
public void setMangaName(String mangaName) {
this.mangaName = mangaName;
}
/**
* @return the mangaLink
*/
public String getMangaLink() {
return mangaLink;
}
/**
* @param mangaLink the mangaLink to set
*/
public void setMangaLink(String mangaLink) {
this.mangaLink = mangaLink;
}
/**
* @return the mangaAlpha
*/
public String getMangaAlpha() {
return mangaAlpha;
}
/**
* @param mangaAlpha the mangaAlpha to set
*/
public void setMangaAlpha(String mangaAlpha) {
this.mangaAlpha = mangaAlpha;
}
/**
* @return the _id
*/
public int get_id() {
return _id;
}
/**
* @param _id the _id to set
*/
public void set_id(int _id) {
this._id = _id;
}
}
行:
MangaItemDB.mangaCount = String.valueOf(mangaCount);
MangaItemDB.alphaCount = Integer.toString(getAlphaCount());
MangaItemDB.mangaComplete = String.valueOf(getMangaComplete());
都给出“类型不匹配:无法从 String 转换为 Int”