gpt4 book ai didi

安卓 SQL 错误

转载 作者:行者123 更新时间:2023-11-30 04:46:28 25 4
gpt4 key购买 nike

我一直在学习使用 SQL 数据库的教程,我认为我遇到了一些问题,因为它已经写了一段时间了。

例如,它有 this.createDatabase,必须用 this.openOrCreateDatabase 替换,我用 Google 找到了这个。还有其他问题我找不到解决方案:Query、Results、Next、setListAdapter 都显示错误。

这实际上是问题所在,教程是为早期的 SDK 创建的吗?有人可以告诉我去哪里查看已弃用的方法及其替换方法,或者指出我应该用什么来替换上面的方法?

抱歉,我才刚刚开始,希望您能理解我的意思。非常感谢您的帮助。

编辑:教程在这里:http://www.anddev.org/novice-tutorials-f8/working-with-the-sqlite-database-cursors-t319.html

问题出在下面的代码中,c.first、results.add、c.next、this.setListAdapter和最后一行大部分都有错误

if (c.first()) {
int i = 0;
/* Loop through all Results */
do {
i++;
/* Retrieve the values of the Entry
* the Cursor is pointing to. */
String firstName = c.getString(firstNameColumn);
int age = c.getInt(ageColumn);
String ageColumName = c.getColumnName(ageColumn);

/* Add current Entry to results. */
results.add("" + i + ": " + firstName
+ " (" + ageColumName + ": " + age + ")");
} while (c.next());
}
}

} catch (FileNotFoundException e) {
} finally {
if (myDB != null)
myDB.close();
}
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1_small, results));

}

最佳答案

您可以查看示例记事本源代码 NotepadProvider , NoteEditorNoteList实现。

关于安卓 SQL 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4851273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com