-
Notifications
You must be signed in to change notification settings - Fork 1
/
ViewContacts.java
47 lines (38 loc) · 1.43 KB
/
ViewContacts.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.example.tarun.auxilium;
import android.database.Cursor;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
public class ViewContacts extends AppCompatActivity
{
ArrayList<String> contact=new ArrayList<>();;
ListView myListView;
String id,name,phoneNo;
private ArrayAdapter myAdapter;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out);
setContentView(R.layout.activity_view_contacts);
final ContactsDatabaseHandler handler= new ContactsDatabaseHandler(this);
myAdapter = new ImportContactsCustomAdapter(this, contact);
myListView = (ListView)findViewById(R.id.listView2);
myListView.setAdapter(myAdapter);
// getSharedPreferences();
Cursor cursor=handler.getListContacts();
if(cursor!=null && cursor.moveToFirst())
{ do
{
name=cursor.getString(cursor.getColumnIndex("name"));
phoneNo=cursor.getString(cursor.getColumnIndex("number"));
contact.add(name+"\n("+phoneNo+")");
myAdapter.notifyDataSetChanged();
cursor.moveToNext();
}while (!cursor.isAfterLast());
cursor.close();
}
}
}