java - How to identify a piece of data in an SQLite database's column? -


This is my first time installing a SQLite database, and I have trouble knowing how to control the cursor Suppose that my column names are (author, year published, title) in that order. And says that I have already saved some entries in the data base:

  1. Bob, 2007, "Builder"
  2. Jack, 2003, "Headless Horseman"
  3. Andy, 2012, "The mistress Legend"

So for each book title there is a button with the names of the books on it (for example, "The Builder "On a user-created button) Users can then click on this button, go to another activity page Not, and may already have information about this book. For example, it is almost like a library where a new book called "Green egg and ham" is called Dr. , Published: The user goes through the other parts of my app, by entering the information of this book, thus saving data as an entry in the SQLite database and with it on "Green Eggs and Hams" Creating a button and when the user clicks on this button, he goes to a page with the information:

Author: Dr. Saas / published: 1960 / title: Green eggs and ham

My question is, how can I identify a title in my database like "Green eggs and ham" and then all other information I can get it.

My thoughts about how I want to work:

  Cursor = Database column ("Heading"). StringWith ID ("Greenings Andham") GetRowInformation (); String title = cursor.jet ("title"); Int published = cursor.get ("publish the year"); String author = cursor.get ("author")  

But obviously this is not a valid syntax.

My database code:

  public class datahandler {public static final string prefix = "priority"; Public Stable Last String At least = "Low Horse"; Public static final string at least minutes = "least minutes"; Public stable final string EXACTHOURS = "exacthors"; Public static final string EXACTMINUTES = "precise minute"; Public static final string SETHOURS = "setHours"; Public static final string SETMINUTES = "setMinutes"; Public static final string SETAMPM = "setAmPm"; Public static final string ACTIVITYNAME = "activityName"; Public static final string TABLE_NAME = "mytable"; Public static final string DATA_BASE_NAME = "mydatabase"; Public static final end DATABASE_VERSION = 1; Public static final string TABLE_CREATE = "Create table minetable (name text is not empty, email text is not empty);"; Database Helper Dblfer; Reference CTX; SQLiteDatabase db; Public DataHandler (Reference CTX) {this.ctx = ctx; Dbhelper = New Database Helper (CTX); } Private Static Class Database Helper SQLiteOpenHelper {Public DatabaseHelper (Reference CTX) {Super (CTX, DATA_BASE_NAME, blank, DatabaseBVSINS) extends; } @ Override Creature on Public Zero (SQLiteDatabase DB) {try {db.execSQL (TABLE_CREATE); } Hold (RuntimeException e) {e.printStackTrace (); }} @ Override Public Video OnUpgrade (SQLiteDatabase DB, Int JuniorWarson, It Newversion) {DBXACSQL ("Drop Tablet Initiative Meetable"); OnCreate (database); }} Public DataHeader Open () {db = dbhelper.getWritableDatabase (); This return; } Public Zero Closure () {dbhelper.close (); } Public long Insertata (difference priority, at least hosh, minimal minutts, int exactor, exact completeness, int sethors, intetiminate, string setammp, string activity name) {content value content = new content value (); Content.put (priority, priority); Content.put (at least, at least); Content.put (at least minutes, at least); Content.put (EXACTHOURS, exactHors); Content.put (EXACTMINUTES, exact minutes); Content.put (SETHOURS, sethones); Content.put (SETMINUTES, setnaments); Content.put (SETAMPM, setAmPm); Content.put (ACTIVITYNAME, activity name); Return db.insertOrThrow (TABLE_NAME, empty, content); } Public cursor return data (return) db.query (TABLE_NAME, new string [] (priority, atleast, at least, extrashers, extammants, setter, settings, setumapam, activity}}, empty, empty, Null, void;}  

}

you can use

<("title", "WordPrinted", "author"}, "title" + "'%" + title + "%'", blank, empty, empty, zero);}

and then read the details:

  cursor cursor = dbhandler GetDetailsForBook ("Green eggs and ham"); ​​String title = Cursor.gate string (cursor.gate column index ("title")); Int published = cursor.getINt = CursorGetString (cursor.gatecolumnindex ("author"));  

Hope it helps.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -