Note that there are some explanatory texts on larger screens.

plurals
  1. POGetting the value of the ArrayList<HashMap<String,String>> for display
    text
    copied!<p>Hi I just want to know better on how to use this. Since I'm using this kind of method in doing my custom listView now I wanted to apply it since I love the approach on this but I don't know how I should do it. Anyway What I have is a database query where I get all the result from a search query in SQLite Database. Now I'm sure about the content of my query since I already tested it but when I display it the result always return the same output which is the last row of the query. For better understanding here's my code:</p> <pre><code>public ArrayList&lt;HashMap&lt;String,String&gt;&gt; getList(String search_param){ SQLiteDatabase db = this.getWritableDatabase(); ArrayList&lt;HashMap&lt;String,String&gt;&gt; list = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;(); HashMap&lt;String,String&gt; hashmap = new HashMap&lt;String,String&gt;(); String query_select = "SELECT column1, column2 FROM tablename WHERE column2 LIKE '%"+ search_param +"%';"; Cursor cursor = db.rawQuery(query_select,null); if (cursor.moveToFirst()) { do { item_list.put("column1", cursor.getString(0)); item_list.put("column2",cursor.getString(1)); list.add(hashmap); } while (cursor.moveToNext()); } cursor.close(); return list; } </code></pre> <p>now to retrieve the list here's what I tried so far:</p> <pre><code> ArrayList&lt;HashMap&lt;String,String&gt;&gt; new_list; DatabaseClass db = new DatabaseClass(getActivity()); new_list = db.getList(""); for(int i=0;i&lt;new_list.size();i++){ HashMap&lt;String,String&gt; content = new HashMap&lt;String, String&gt;(); content = new_list.get(i); Log.v("The hashmap",content.get("column1").toString()); Log.v("The hashmap",content.get("column2").toString()); } </code></pre> <p>now the content of my Database should be 1,2,3 for column1 and test1,test2,test3 for column2. but what I get from the result are 3,3,3 and test3,test3,test3</p> <p>I also tried the method of doing <code>newlist.get(i).get("column1").toString;</code> but it doesn't even solve the problem.</p> <p>Any idea on what I should do about this?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload