package com.ntels.nfriends;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;
public class ActPush extends Activity implements OnClickListener{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.push_mag);
Button sync = (Button)findViewById(R.id.msg_send);
sync.setOnClickListener(this);
}
public ArrayList<ContactListItem> GetArrayListData(String strFind, int nType) {
ArrayList<ContactListItem> arrayList = new ArrayList<ContactListItem>();
InputStream fis = null;
BufferedReader br = null;
try {
String inputdata = "";
String strItemID = "";
String strLeftText = "";
String strRightText = "";
String strLeft2Text = "";
String strRight2Text = "";
String strPhone = "";
String strEmail = "";
String strPhoto = "";
String [] keyValue;
br = new BufferedReader(new InputStreamReader(new FileInputStream("list.txt"),"UTF8"));
inputdata = br.readLine();
while( (inputdata = br.readLine()) != null )
{
keyValue = inputdata.split("\\t");
if( nType > 0 )
{
if( keyValue[nType].indexOf(strFind) < 0 )
{
continue;
}
}
strItemID = keyValue[0];
strLeftText = keyValue[3]; //이름
strRightText = keyValue[4];
strLeft2Text = keyValue[1];
strRight2Text = keyValue[2]; //조직
strPhone = keyValue[5];
strEmail = keyValue[6];
strPhoto = keyValue[7];
ContactListItem itemDemoList = new ContactListItem(strItemID, strLeftText, strRightText, strLeft2Text, strRight2Text, strPhone, strEmail, strPhoto);
//하나씩받아서 한줄을 완성시킨다.
arrayList.add(itemDemoList);
//한줄씩 배열로 저장
}
br.close();
} catch (Exception e) {
Log.e("Net", "Failed in parsing List", e);
}
return arrayList;
}
public void onClick(View v)
{
Toast.makeText(ActPush.this,
"동기화",Toast.LENGTH_LONG).show();
}
}
제가하려는소스가 텍스트파일이 생긴걸 읽어들여서 개체1개씩만든다음(이게 맞는지 모르겠네요.)
그객체를이용하여 내부주소록과 동기화를 시도할라고합니다.
저 파일 읽는부분이 읽어지는지가 궁금합니다... 그리고 strPhone 이걸 onClick쪽에 쓰려고하는데 쓰질못하네요...
프로그래머분들의 조언을 구하고자 질문을 올립니다..