Java Android-SQLite数据库到字符串
我有一个“小”问题,我有SQLite数据库,我需要从表“Champions”列“displayName”中获取所有值(文本)到字符串,并按id调用它们以在textview中显示?我找不到已经两个小时了。。。有解决办法吗?(我需要从一列中获取字符串,按id排序。在加载活动时,在textview中显示文本值,按id调用。)有好的解决方案吗?非常感谢您的回复 对不起,我的英语不好,问了一个愚蠢的问题,但我是编程新手(只是java,我对使用Visual Basic有点在行) 编辑:或仅将列导出为xml字符串。我可以这样做吗?感谢使用DataBaseHelper:Java Android-SQLite数据库到字符串,java,android,sqlite,Java,Android,Sqlite,我有一个“小”问题,我有SQLite数据库,我需要从表“Champions”列“displayName”中获取所有值(文本)到字符串,并按id调用它们以在textview中显示?我找不到已经两个小时了。。。有解决办法吗?(我需要从一列中获取字符串,按id排序。在加载活动时,在textview中显示文本值,按id调用。)有好的解决方案吗?非常感谢您的回复 对不起,我的英语不好,问了一个愚蠢的问题,但我是编程新手(只是java,我对使用Visual Basic有点在行) 编辑:或仅将列导出为xml字
DataBaseHelper myDbHelper = new DataBaseHelper(this.context, "animals.db");
try {
myDbHelper.createDataBase();
} catch (IOException ioe) {
Toast.makeText(context,
context.getString(R.string.error), Toast.LENGTH_SHORT).show();
throw new Error("Unable to create database");
}
try {
myDbHelper.openDataBase();
} catch (SQLException sqle) {
Toast.makeText(context,
context.getString(R.string.error), Toast.LENGTH_SHORT).show();
throw sqle;
}
和光标:
SQLiteDatabase db = myDbHelper.getWritableDatabase();
Cursor c = db.query("animals", null, null, null, null, null, null);
ArrayList<Animals> animals = new ArrayList<Animals>();
int idColIndex = c.getColumnIndex("_id");
int nameColIndex = c.getColumnIndex("name");
ArrayList<String> nameList = new ArrayList<String>();
if (c.moveToFirst()) {
do {
String name = c.getString(nameColIndex);
nameList.add(name);
} while (c.moveToNext());
}
c.close();
db.close();
SQLiteDatabase db=myDbHelper.getWritableDatabase();
游标c=db.query(“动物”,null,null,null,null,null);
ArrayList单个文本视图或列表视图?一些(超过80个)文本视图(或按钮,但这并不重要,将文本更改为一个文本视图或按钮。我正确吗?)