Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在android中将数据从sqlite提取到数组中_Android_Sqlite - Fatal编程技术网

在android中将数据从sqlite提取到数组中

在android中将数据从sqlite提取到数组中,android,sqlite,Android,Sqlite,返回列表中表中所有数据的代码。但这不起作用。 我从CheckData类调用了这个方法,该类由main类调用 public List<String[]> selectAll() { List<String[]> list = new ArrayList<String[]>(); Cursor cursor = db .query(TABLE_NAME, null, null, null, null,

返回列表中表中所有数据的代码。但这不起作用。 我从CheckData类调用了这个方法,该类由main类调用

public List<String[]> selectAll() {
        List<String[]> list = new ArrayList<String[]>();
        Cursor cursor = db
                .query(TABLE_NAME, null, null, null, null, null, null);
        int x = 0;
        if (cursor.moveToFirst()) {
            do {
                String[] b1 = new String[] { cursor.getString(1),
                        cursor.getString(2) };
                list.add(b1);
                x = x + 1;
            } while (cursor.moveToNext());
        }
        if (cursor != null && !cursor.isClosed()) {
            cursor.close();
        }
        cursor.close();
        return list;
    }
public List selectAll(){
列表=新的ArrayList();
游标=分贝
.query(表名称,null,null,null,null,null,null,null);
int x=0;
if(cursor.moveToFirst()){
做{
字符串[]b1=新字符串[]{cursor.getString(1),
cursor.getString(2)};
列表。添加(b1);
x=x+1;
}while(cursor.moveToNext());
}
if(cursor!=null&!cursor.isClosed()){
cursor.close();
}
cursor.close();
退货清单;
}
我的数据库包含3列-id(整型主键)、符号(文本)和公司名称(文本)


我的数据库名是AppDB,表名是scrip。

以下是学习使用Android SQLite的好教程。
所以,我也建议你,就像我回答的一样,什么是不起作用的?你看到了什么?首先解释一下你想问什么…@zmbq-当我运行应用程序时,首先我看到一个按钮,然后我点击它。它应该显示数据库中的所有数据,但它显示应用程序已经停止工作。我的基本目的是在ANDROID EMULATOR上显示数据,它存储在已经创建的SQLITE数据库中。我能做什么呢?但所有这些教程都展示了我们在编码过程中创建数据库和表的演示。我已经有了数据库。我得去拿数据。伙计,不是那样的。问题是在修改代码以显示现有数据库中的数据之后,它就不起作用了;Log.e(“selectAll方法错误”,b1[x]);x=x+1;和(2)Cursor Cursor=db.rawQuery(“从纸条中选择符号、公司名称”,新字符串[]{“符号”、“公司名称”});我只是看到了另一个问题只是检查一下