数据库需要帮助 [英] Database help needed

查看:126
本文介绍了数据库需要帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个编辑文本字段,一个用于标题,另一个用于故事的活动。结果
该项目由两个文本字段保存在数据库中,也该数据库有一个 ROW_ID 的title_id STORY_ID .The条目显示在列表视图的。结果
当一个项目被长点击我得到对应于该项目的行ID 的。结果
我应该如何获得的title_id STORY_ID 此。

I have an activity which has two edit text fields, one for title and the other for story.
The entries made two text fields are saved in the database, also the database has a ROW_ID,TITLE_ID and STORY_ID.The entries are displayed in a list view.
When an item is long clicked I get the row id corresponding to that item.
How should I get the TITLE_ID and STORY_ID from this.

推荐答案

我说,你有项目的corresponing行ID是一个可变长的点击摆脱。然后运行以下查询:

Say, you have the corresponing row id of item which is long clicked in a variable rid. Then run the following query:

  String q = "SELECT * FROM TABLE_NAME where(ROW_ID like '"+rid+"')";
  Cursor c = db.rawQuery(q, null); //  db is a object of SQLiteDatabase type  

然后检索的title_id STORY_ID 这样的:

              if(c.getCount() == 0)
              {                   
                 //No entry found
              }
              else  {
                  c.moveToFirst();
                  do {
                      String titleid = c.getString(c.getColumnIndex("TITLE_ID")); 
                      String storyid = c.getString(c.getColumnIndex("STORY_ID"));
                      } while (c.moveToNext());                 
            c.close();


然后用它们作为你喜欢:)


Then use them as you like :)

这篇关于数据库需要帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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