wood burning stoves 2.0*
The moose likes Java in General and the fly likes Help regarding Logic for sqlite database Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Help regarding Logic for sqlite database" Watch "Help regarding Logic for sqlite database" New topic
Author

Help regarding Logic for sqlite database

Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

I am developing an application for Android platform. And I am stuck at one point.This question is not about android specific therefore I am asking it here.

At the start of application I a showing a list of rooms (i.e list containing room names) to the user. User select one room name from this list. Now I want to store this selected item to database. For that I had created one table name as RoomTable. which has 3 columns as - RoomID (primary key), RoomName, and RoomSuffix.

So let suppose user selected room name as Hall then inside database entry becomes as

RoomID RoomName RoomSuffix
1 Hall 0
2 Kitchen 0
3 Hall1 1
4 Hall2 2
5 Bedroom 0

Means suppose user select second time again room name as Hall then it must becomes roomname+roomsuffix (i.e Hall1, Hall2... )

For this I had write following code


But this code doesn't give me the expected output. I got following output.





Life is easy because we write the source code.....
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

To search the suffix you are searching for Hall, but Hall1 and Hall2 do not have Hall as room name.

If I were you I'd keep all room names as Hall, then either calculate the displayed room name or add a new field for the full room name.

So:
1)
In displaying, you append RoomSuffix to RoomName if it isn't 0.

2)

The difference is when you calculate the full name. In 1) it's when displaying, in 2) it's when inserting into the database.

Now you can search for RoomName to find the RoomSuffix.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Pramod P Deore
Ranch Hand

Joined: Jul 15, 2008
Posts: 629

Thanks Rob, you are right. After adding one more column it works fine. Thanks once again.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19680
    
  19

You're welcome.
 
 
subject: Help regarding Logic for sqlite database