Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/197.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 - Fatal编程技术网

如何访问android sqlite应用程序中的特定列值?

如何访问android sqlite应用程序中的特定列值?,android,Android,我有一个应用程序,我想对应用程序中的数据库使用SQL查询返回的值。我想使用将这些值附加到链接到远程主机上的脚本的uri。我正在调用该方法来检索这些值,然后我将提取它们。问题是我在这方面面临着挑战。我懂一点php,我想在android中做的事情就是这样在php中完成的: ....(preceding code)...$row['email']; 现在我可以分配一个变量,例如,$email=$row['email'] 我如何在安卓系统中做到这一点 我不希望返回游标,只希望返回列的值作为字符串 下面

我有一个应用程序,我想对应用程序中的数据库使用SQL查询返回的值。我想使用将这些值附加到链接到远程主机上的脚本的uri。我正在调用该方法来检索这些值,然后我将提取它们。问题是我在这方面面临着挑战。我懂一点php,我想在android中做的事情就是这样在php中完成的:

....(preceding code)...$row['email'];
现在我可以分配一个变量,例如,
$email=$row['email']

我如何在安卓系统中做到这一点

我不希望返回游标,只希望返回列的值作为字符串

下面是我的代码(我需要帮助来检索密码列)

我需要有关插入“密码”列的帮助,以便将其与电子邮件一起返回。

试试这种方法

        String[][] str = new String[cursor.getCount()][cursor.getColumnCount()];

        while (cursor.moveToNext())
        {
             for(int j=0;j<cursor.getColumnCount();j++)
                 str[i][j] = cursor.getString(j); /// may be this column start with the 1 not with the 0

             i++;
         }

你应该像这样改变你的设计

public Cursor selectAll() {    
        Cursor cursor = db.query(DB_TABLE_NAME, new String[] { "email","password"},null, null, null, null,null); 
return cursor;        
    }
Cursor cursor=selectAll();
String[] mail = new String[cursor.getCount()];
String[] pass = new String[cursor.getCount()];
int i=0; 
while (cursor.moveToNext())
            {
                 mail[i] = cursor.getString(cursor.getColumnIndex("email"));
                 pass[i] = cursor.getString(cursor.getColumnIndex("password"));

                 i++;
             }
然后像这样使用selectAll功能

public Cursor selectAll() {    
        Cursor cursor = db.query(DB_TABLE_NAME, new String[] { "email","password"},null, null, null, null,null); 
return cursor;        
    }
Cursor cursor=selectAll();
String[] mail = new String[cursor.getCount()];
String[] pass = new String[cursor.getCount()];
int i=0; 
while (cursor.moveToNext())
            {
                 mail[i] = cursor.getString(cursor.getColumnIndex("email"));
                 pass[i] = cursor.getString(cursor.getColumnIndex("password"));

                 i++;
             }