我怎么可以处理在Android的一个SQLite数据 [英] How can I process a SQLite dataset in Android

查看:189
本文介绍了我怎么可以处理在Android的一个SQLite数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要处理在Android系统的一个SQLite数据集。

I need to process a SQLite dataset in an Android system.

在我dataBaseHelper文件(DataBaseAccessor),我有以下code(这当连接到ListView显示的相关数据)。

In my dataBaseHelper file (DataBaseAccessor) I have the following code (which when attached to a listview shows the relevant data).

public static ArrayList<QuestionListQuestion> getQuestionListQuestions(long id){
String qry = "select QuestionListQuestionID, QuestionListQuestionQuestionListID, QuestionListQuestionQuestionID, QuestionListQuestionSortOrder, QuestionListQuestionSupplementalQuestionIDYes, QuestionListQuestionSupplementalQuestionIDNo, QuestionListQuestionSupplementalQuestionIDText, QuestionListQuestionSurveyGroupID from QuestionListQuestion  where  QuestionListQuestionQuestionListID=" + id;
ArrayList<QuestionListQuestion> list = new ArrayList<QuestionListQuestion>();
try{
    Cursor cursor = wdb.rawQuery(qry, null);
while (cursor.moveToNext()) {
QuestionListQuestion questionlistquestion = new QuestionListQuestion();
    questionlistquestion.QuestionListQuestionID = cursor.getLong(0);
    questionlistquestion.QuestionListQuestionQuestionListID = cursor.getLong(1);
    questionlistquestion.QuestionListQuestionQuestionID = cursor.getLong(2);
    questionlistquestion.QuestionListQuestionSortOrder = cursor.getLong(3);
questionlistquestion.QuestionListQuestionSupplementalQuestionIDYes = cursor.getString(4);       questionlistquestion.QuestionListQuestionSupplementalQuestionIDNo = cursor.getString(5);
questionlistquestion.QuestionListQuestionSupplementalQuestionIDText = cursor.getString(6);
questionlistquestion.QuestionListQuestionSurveyGroupID = cursor.getLong(7);
list.add(questionlistquestion);
}
    cursor.close();
}
catch (Exception e) {
    e.printStackTrace();
}
return list;
}

我现在需要基于原始列表上的另一台扩展系统,这样我可以处理这些数据,并创造新的纪录回来了。

I now need to extend the system so that I can process the data and create new records in another table based on the original list returned.

我尝试了以下附加到按钮(选择从微调的有关名单ID): -

I tried the following attached to a button (selecting the relevant list ID from a spinner):-

QuestionListID = (String) SiteGenerateQuestions.this.spnQuestL.getSelectedItem().toString();
long SpinnerSelectedBT;
SpinnerSelectedBT = GenerateQuestions.this.spnQuestL.getSelectedItemId();
list = DatabaseAccessor.getQuestionListQuestions(SpinnerSelectedBT);
for (int i=0; i < list.size(); i++){
Toast.makeText(SiteGenerateQuestions.this," list.get(" + i + ")   = " + list.get(i) + " "  , Toast.LENGTH_SHORT).show();
}

敬酒显示以下内容: -

The Toast displays the following:-

list.get(0) =  com.tw.question.entity.QuestionListQuestion@407a6F70
list.get(1) =  com.tw.question.entity.QuestionListQuestion@407bc170
etc...

我怎样才能进入实际数据,而不是... .entity.QuestionListQuestion @ 407bc170还是我完全偏离了轨道?

How can I get access to the actual data instead of ... .entity.QuestionListQuestion@407bc170 or am I completely off-track?

非常感谢

推荐答案

我@wsanville的的get()法同意将返回对象列表中的那个位置。当您打印出一个对象(在祝酒,日志的System.out.println等),它会在打印输出使用的toString()值。默认的toString()是软件包的名称后面@后面是该对象的十六进制再presentation。您的类将需要重写的toString()方法,以便当您使用的get()它会打印出任何你把你的的toString()方法。

I agree with @wsanville the get() method will return the object in that location of the list. When you print out an object (in a toast, log, System.out.println etc) it will use the toString() value in the printout. The default toString() is the package name followed by @ which is followed by a hex representation of that object. Your class will need to override the toString() method so when you use get() it will print out whatever you put in your toString() method.

这篇关于我怎么可以处理在Android的一个SQLite数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆