sree_iphonedev
sree_iphonedev

Reputation: 3534

Manipulating Database operation and Dictionary concept

I am new in Android app development. Now I am writing a singleton class for manipulating database operation. In case of select query, I am planning to store the "table field name" as key and data of each row in a dictionary. Then each dictionary of row data is stored in an Array. I have implemented this concept in iOS. But as I am new to Android, I don't how the dictionary concept can be implemented in Android. Does this is available in Android? If so can anybody help me to implement.

Thanks in advance.

Upvotes: 0

Views: 219

Answers (1)

Samir Mangroliya
Samir Mangroliya

Reputation: 40426

in ios may be dictionary is save data as key/pair value

and in android we have HashMap<Key,Value>

Map<Intger,String> map = new HashMap<Integer,String>();

here Integer is key and String is value

//Add data in map

map.put(1,"string1");
map.put(2,"string2");

NOTE ::

Mind that key is unique not allowed duplicates and if you need ordered data then use LinkedHashmap instead of Hashmap

//retrieve data

for(Map.Entry<Integer,String> entry :map.entrySet())
{
    int i = entry.getKey();
    String s = entry.getValue();
}

Upvotes: 1

Related Questions