2016-04-30 8 views
0

Ich habe bereits alle Kontaktnummer (Name, Nummer) in Array und Anzeige in Listview .. Ich weiß schon, wie man Einzelwert in die Datenbank mit Volley einfügen, aber ich weiß es nicht wie man ein Array einfügtWie bekomme ich alle Wert in Array Android und Einfügen in die Datenbank

 cursor1 = getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null); 
     startManagingCursor(cursor1); 

     String[] from = {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME, ContactsContract.CommonDataKinds.Phone.NUMBER, ContactsContract.CommonDataKinds.Phone._ID}; 

     int[] to = {android.R.id.text1, android.R.id.text2}; 

     SimpleCursorAdapter listadapter = new SimpleCursorAdapter(this, android.R.layout.simple_list_item_2, cursor1, from, to); 
     setListAdapter(listadapter); 
     lv = getListView(); 

Volley

@Override 
      protected Map<String, String> getParams() throws AuthFailureError { 
       Map<String,String> params = new HashMap<>(); 
       //Adding parameters to request 
       params.put("fromV", from); 

ich Fehler bekommen bei Temperaturen von in params.put ..

Antwort

0

Sie sollten String übergeben als zweite param, aber sie sind vorbei String []; wenn Sie nur Arraylist müssen dann konvertieren String [] Liste siehe this

0

Sie so etwas für Insert-Array tun können

public void Insert_phone_contact(String [] contact){//Arrary of your contacts 
try{ 

SQLiteDatabase DB = this.getWritableDatabase(); 
ContentValues cv = new ContentValues(); //put your contacts in the content values in the loop 
for(int i=0;i<contact.length;i++){    
    cv.put(CONTACT_NAME, contact[i]); 
    DB.insert(TABLE_CONTACTS, null, cv); //Insert each time for loop count    
} 
DB.close(); // Now close the DB Object 
} 
catch(Exception ex){ 
Log.e("Error in phone contact insertion", ex.toString()); 
}