Add code:
package com.example.system_3.multimapper;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class Add extends AppCompatActivity {
private SQLiteHelper SQLHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add);
SQLHelper = new SQLiteHelper(this);
Button b=(Button) findViewById(R.id.button1);
// Button b1=(Button)findViewById(R.id.button2);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
EditText e1=(EditText)findViewById(R.id.editText1);
EditText e2=(EditText)findViewById(R.id.EditText01);
EditText e3=(EditText)findViewById(R.id.EditText02);
EditText e4=(EditText)findViewById(R.id.EditText03);
String j=e2.getText().toString();
String j1=e3.getText().toString();
String h=j+","+j1;
SQLHelper.insertData(e1.getText().toString(), h,e4.getText().toString());
Toast.makeText(Add.this, "Successfully added", 10).show();
Intent i = new Intent(Add.this, Home.class)
startActivity(i);
});
/*b1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(Add.this, Home.class);
startActivity(i);
});
*/
Find code(list):
package com.example.system_3.multimapper;
import java.util.ArrayList;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;
public class Find extends AppCompatActivity {
private SQLiteHelper SQLHelper;
/* String si,sk;
ListView lv ;
ArrayList<String[]> DATA = new ArrayList<String[]>();
EditText ed1,ed2;*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_find);
Button b=(Button)findViewById(R.id.button1);
// Button b1=(Button)findViewById(R.id.button2);
ArrayList<String[]> DATA = new ArrayList<String[]>();
ListView lv ;
SQLHelper = new SQLiteHelper(this);
lv=(ListView)findViewById(R.id.listView1);
DATA=SQLHelper.selectalldatabase();
if(!DATA.isEmpty())
lv.setAdapter(new MyCustomBaseAdapter(this, DATA));
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v,int position, long arg3)
// position parameter gives the index or position of ListView Item which is Clicked
TextView tv1=(TextView)v.findViewById(R.id.textView2);
TextView tv=(TextView)v.findViewById(R.id.textView1);
TextView tv2=(TextView)v.findViewById(R.id.textView3);
String ad=tv1.getText().toString();
String n=tv.getText().toString();
String ph= tv2.getText().toString();
Intent i = new Intent(Find.this, MapsActivity.class);
i.putExtra("address", ad);
i.putExtra("name", n);
i.putExtra("phone", ph);
startActivity(i);
});
}
Home code:
package com.example.system_3.multimapper;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Home extends AppCompatActivity {
Button b1,b2;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
b1=(Button)findViewById(R.id.button1);
b2=(Button)findViewById(R.id.Button01);
b1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent in=new Intent(Home.this,Add.class);
startActivity(in);
}
});
b2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent in=new Intent(Home.this,Find.class);
startActivity(in);
});
Main Activity code:
package com.example.system_3.multimapper;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Handler;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
private static int SPLASH_SCREEN_TIME = 1500;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
new Handler().postDelayed(new Runnable() {
public void run() {
// This is method will be executed when SPLASH_SCREEN_TIME is
// over, Now you can call your Home Screen
Intent iHomeScreen = new Intent(getApplicationContext(),
Home.class);
startActivity(iHomeScreen);
// Finish Current Splash Screen, as it should be visible only
// once when application start
finish();
}, SPLASH_SCREEN_TIME);
Map Activity code :
package com.example.system_3.multimapper;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Address;
import android.location.Geocoder;
import android.os.Bundle;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.IOException;
import java.util.List;
public class MapsActivity extends FragmentActivity {
EditText location_tf;
String location,na;
private GoogleMap mMap;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
location_tf = (EditText)findViewById(R.id.TFaddress);
Intent i = getIntent();
// Place referece id
String ad = i.getStringExtra("address");
na=i.getStringExtra("name");
// String ph=i.getStringExtra("phone");
location_tf.setText(ad);
setUpMapIfNeeded();
/* findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
location = location_tf.getText().toString();
Intent i = new Intent(MapsActivity.this,
MapsActivity.class);
Toast.makeText(MapsActivity.this,location,Toast.LENGTH_LONG).show();
startActivity(i);
});*/
@Override
protected void onResume() {
super.onResume();
setUpMapIfNeeded();
public void onSearch(View view){
location = location_tf.getText().toString();
List<Address> addressList = null;
if(location !=null || !location.equals(""))
Geocoder geocoder= new Geocoder(this);
try {
addressList = geocoder.getFromLocationName(location, 1);
} catch (IOException e) {
e.printStackTrace();
Address address = addressList.get(0);
LatLng LatLng = new LatLng(address.getLatitude(),address.getLongitude());
mMap.addMarker(new MarkerOptions().position(LatLng).title(na));
mMap.animateCamera(CameraUpdateFactory.newLatLng(LatLng));
private void setUpMapIfNeeded() {
if (mMap == null) {
mMap = ((SupportMapFragment)
getSupportFragmentManager().findFragmentById(R.id.map))
.getMap();
if (mMap != null) {
setUpMap();
private void setUpMap() {
if (ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(this,
Manifest.permission.ACCESS_COARSE_LOCATION) !=
PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
My custom Base adapter code(view list of friends):
package com.example.system_3.multimapper;
import java.util.ArrayList;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class MyCustomBaseAdapter extends BaseAdapter {
private static ArrayList<String[]> searchArrayList;
private LayoutInflater mInflater;
public MyCustomBaseAdapter(Context context, ArrayList<String[]> results) {
searchArrayList = results;
mInflater = LayoutInflater.from(context);
public int getCount() {
return searchArrayList.size();
}
public Object getItem(int position) {
return searchArrayList.get(position);
public long getItemId(int position) {
return position;
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list, null);
holder = new ViewHolder();
holder.txtName = (TextView) convertView.findViewById(R.id.textView1);
holder.txtCityState = (TextView) convertView
.findViewById(R.id.textView2);
holder.txtPhone = (TextView) convertView.findViewById(R.id.textView3);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
String []s=searchArrayList.get(position);
holder.txtName.setText(s[0]);
holder.txtCityState.setText(s[1]);
holder.txtPhone.setText(s[2]);
return convertView;
static class ViewHolder {
TextView txtName;
TextView txtCityState;
TextView txtPhone;
SQLite helper code:
package com.example.system_3.friendmapper;
import java.util.ArrayList;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
public class SQLiteHelper {
public static ArrayList<String[]> DATA = new ArrayList<String[]>();
private static final String DATABASE_NAME = "friendmapper.db";
private static final int DATABASE_VERSION = 1;
private static final String STUDENT_TABLE = "friend";
private Context context;
private SQLiteDatabase db = null;
OpenHelper openHelper;
public SQLiteHelper(Context context) {
this.context = context;
if (db != null)
if (db.isOpen())
db.close();
openHelper = new OpenHelper(this.context);
this.db = openHelper.getWritableDatabase();
public void close() {
if (openHelper != null) {
openHelper.close();
public int insertData(String name, String address, String contact) {
int entryId = 0;
ContentValues values = new ContentValues();
values.put("name", name);
values.put("address", address);
values.put("contact", contact);
entryId = (int) this.db.insert(STUDENT_TABLE, null, values);
return entryId;
public ArrayList<String[]> selectdatabase(String search) {
Cursor c = null;
DATA.clear();
String[] columns = new String[] { "id", "name", "address", "contact" };
c = db.query(STUDENT_TABLE, columns,
"name=? OR address=? OR contact=?", new String[] { search,
search, search }, null, null, "id DESC");
if (c.moveToFirst()) {
do {
if (c.getColumnCount() == 4) {
String[] str = new String[3];
str[0] = c.getString(1);
str[1] = c.getString(2);
str[2] = c.getString(3);
DATA.add(str);
} while (c.moveToNext());
if (c != null && !c.isClosed()) {
c.close();
return DATA;
public ArrayList<String[]> selectalldatabase() {
Cursor c = null;
DATA.clear();
String[] columns = new String[] { "id", "name", "address", "contact" };
c = db.query(STUDENT_TABLE, columns, null, null, null, null, "id DESC");
if (c.moveToFirst()) {
do {
if (c.getColumnCount() == 4) {
String[] str = new String[3];
str[0] = c.getString(1);
str[1] = c.getString(2);
str[2] = c.getString(3);
DATA.add(str);
} while (c.moveToNext());
if (c != null && !c.isClosed()) {
c.close();
return DATA;
static class OpenHelper extends SQLiteOpenHelper {
OpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL("CREATE TABLE " + STUDENT_TABLE + "("
+ "id INTEGER PRIMARY KEY, " + "name TEXT, "
+ "address TEXT, " + "contact TEXT)");
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
Log.w("Catch DB",
"Upgrading database, this will drop tables and recreate.");
db.execSQL("DROP TABLE IF EXISTS " + STUDENT_TABLE);
onCreate(db);
public SQLiteDatabase getWritableDatabase() {
// TODO Auto-generated method stub
return null;
Design Coding (XML Coding) :
ADD coding:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#2D2D2D"
tools:context=".Add" >
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/relativeLayout1"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/relativeLayout1"
android:background="#44B6C8"
android:layout_marginBottom="17dp"
android:text="SUBMIT" />
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="250dp"
android:layout_height="330dp"
android:layout_above="@+id/button1"
android:layout_centerHorizontal="true"
android:layout_marginBottom="24dp"
android:background="#AAffffff" >
<EditText
android:id="@+id/editText1"
android:layout_width="215dp"
android:layout_height="40dp"
android:hint="Name"
android:gravity="center"
android:textColorHint="#3DB6C9"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="40dp"
android:background="#ffffff"
android:ems="10" />
<EditText
android:id="@+id/EditText01"
android:layout_width="215dp"
android:layout_height="40dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="113dp"
android:background="#ffffff"
android:hint="City"
android:gravity="center"
android:textColorHint="#3DB6C9"
android:ems="10" >
<requestFocus />
</EditText>
<EditText
android:id="@+id/EditText02"
android:layout_width="215dp"
android:layout_height="40dp"
android:layout_alignLeft="@+id/editText1"
android:layout_below="@+id/editText1"
android:layout_marginTop="110dp"
android:hint="State"
android:gravity="center"
android:textColorHint="#3DB6C9"
android:background="#ffffff"
android:ems="10" />
<EditText
android:id="@+id/EditText03"
android:layout_width="215dp"
android:layout_height="40dp"
android:layout_alignLeft="@+id/EditText01"
android:layout_alignParentBottom="true"
android:layout_marginBottom="25dp"
android:background="#ffffff"
android:hint="Mobile No"
android:gravity="center"
android:textColorHint="#3DB6C9"
android:ems="10" />
</RelativeLayout>
<ImageView
android:id="@+id/imageView1"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:src="@drawable/social" />
</RelativeLayout>
Find coding:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff" >
<ListView
android:id="@+id/listView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
>
</ListView>
</LinearLayout>
Home coding:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/home" tools:context=".Home" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:background="#66FFFFFF" >
<Button
android:id="@+id/button1"
style="?android:attr/buttonStyleSmall"
android:layout_width="220dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#F16B96"
android:textColor="#ffffff"
android:textStyle="bold"
android:paddingRight="10dp"
android:textSize="20sp"
android:drawableRight="@drawable/add"
android:text="ADD ME TO LIST" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="19dp"
android:background="#66FFFFFF" >
<Button
android:id="@+id/Button01"
style="?android:attr/buttonStyleSmall"
android:layout_width="220dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#F16B96"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:paddingLeft="10dp"
android:textSize="20sp"
android:drawableLeft="@drawable/search"
android:text="FIND FRIENDS" />
</RelativeLayout>
</RelativeLayout>
Main coding:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/splash1"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
</RelativeLayout>
Map coding :
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#76B2E6"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:layout_width="200dp"
android:layout_height="50dp"
android:visibility="gone"
android:id="@+id/TFaddress"
android:layout_marginTop="10dp" />
<Button
style="?android:attr/buttonStyleSmall"
android:layout_width="384dp"
android:layout_height="wrap_content"
android:text="Find Friend Location"
android:id="@+id/Bsearch"
android:background="#F86812"
android:layout_gravity="right"
android:onClick="onSearch" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:layout_width="384dp"
android:layout_height="579dp"
android:id="@+id/map"
tools:context="com.example.sys_20.maps.MapsActivity"
android:name="com.google.android.gms.maps.SupportMapFragment"/>
</LinearLayout>
List coding :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@drawable/list3"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textColor="#e04e41"
android:textSize="18dip"
android:textStyle="bold" />
<TextView
android:id="@+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
android:textColor="#41E053"
android:textSize="18dip"
android:textStyle="bold" />
<TextView
android:id="@+id/textView3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#41E053"
android:padding="10dip"
android:textStyle="bold"
android:textSize="18dip"/>
</LinearLayout>