java - Arraylist hashmap android -


i have hashmap of contacts , numbers saved arraylist keep having error " missing method body or declare abstract " private static arraylist> getcontacts();

i able contacts , numbers out , show toast need save , move sqlite database.

import android.app.activity; import android.content.contentresolver; import android.content.intent; import android.database.cursor; import android.net.uri; import android.provider.contactscontract; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.util.log; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.textview; import android.widget.toast;  import java.util.arraylist; import java.util.hashmap;   public class contacts extends actionbaractivity { private static final int pick_contact = 1; //new code private static arraylist<hashmap<string, string>> getcontacts();  private arraylist<hashmap<string, string>> data = new arraylist<hashmap<string, string>>();  private hashmap<string, string> contacts = new hashmap<string,string>(); //stop new code  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_contacts);  }  public void btnaddcontacts_click(view view) {     intent intent = new intent(intent.action_pick, contactscontract.contacts.content_uri);     startactivityforresult(intent, pick_contact); }  public void btndone_click(view view){     intent = new intent(contacts.this, message.class);     startactivity(i); }    @override public void onactivityresult(int reqcode, int resultcode, intent data) {     super.onactivityresult(reqcode, resultcode, data);      switch (reqcode) {         case (pick_contact):             if (resultcode == activity.result_ok) {                 uri contactdata = data.getdata();                 cursor c = managedquery(contactdata, null, null, null, null);                 if (c.movetofirst()) {                     string id =                             c.getstring(c.getcolumnindexorthrow(contactscontract.contacts._id));                      string hasphone =                             c.getstring(c.getcolumnindex(contactscontract.contacts.has_phone_number));                      if (hasphone.equalsignorecase("1")) {                         cursor phones = getcontentresolver().query(                                 contactscontract.commondatakinds.phone.content_uri, null,                                 contactscontract.commondatakinds.phone.contact_id + " = " + id,                                 null, null);                         phones.movetofirst();                         string phn_no = phones.getstring(phones.getcolumnindex("data1"));                         string name = c.getstring(c.getcolumnindex(contactscontract.commondatakinds.structuredpostal.display_name));  //all new code added below                         contacts.put(name, phn_no);                           while (c.movetonext()) {                             string id1 =     c.getstring(c.getcolumnindex(contactscontract.contacts.lookup_key));                              string name1 = contacts.get(id1);                             string phone =     c.getstring(c.getcolumnindex(contactscontract.commondatakinds.phone.data));                              hashmap<string, string> h = new hashmap<string, string>();                             h.put("name", name1);                             h.put("phone", phone);                             data.add(h);                         }  //the toast goes old code. works fine.                          toast.maketext(this, "contact info : " + phn_no + "\n" + name, toast.length_long).show();                      }                 }             }     }  }   } 

private static arraylist<hashmap<string, string>> getcontacts; 

remove () - these methods , calling constructors initialize objects. if want initialize use

private static arraylist<hashmap<string, string>> getcontacts = new arraylist<hashmap<string, string>>(); 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -