오라클/jsp/안드로이드를 연동해서 안드로이드에 쓴 내용이 오라클 테이블에 저장이 되도록 연동 하고있습니다.
롱클릭 리스트로 삭제를 하는데 어플내에서는 삭제가 되지만 db가 삭제되지 않습니다. 혹시 db를 삭제 하려면 어떤 방향으로
해결해야 할지 가르쳐 주시면 너무너무 감사하겠습니다. 아래는 소스 코드 입니다.
public class MainActivity extends Activity {
Button btn;
ListView lv;
ArrayList<EmpDTO> list;
CustomAdapter adapter;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
lv = (ListView) findViewById(R.id.listView1);
btn = (Button) findViewById(R.id.button1);
btn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(),
InsertActivity.class);
startActivity(intent);
}
});
}
public InputStream requestGet(String requestURL) {
Log.i("xxx", "requestGet start");
try {
HttpClient client = new DefaultHttpClient();
List<NameValuePair> List = new ArrayList<NameValuePair>();
HttpGet get = new HttpGet(requestURL);
HttpResponse response = client.execute(get);
HttpEntity entity = response.getEntity();
InputStream is = entity.getContent();
return is;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public String streamToString(InputStream is) {
StringBuffer buffer = new StringBuffer();
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
is, "utf-8"));
String str = reader.readLine();
while (str != null) {
buffer.append(str + "\n");
str = reader.readLine();
}
reader.close();
} catch (Exception e) {
e.printStackTrace();
}
return buffer.toString();
}
public ArrayList<EmpDTO> getXML(InputStream is) {
ArrayList<EmpDTO> list = new ArrayList<EmpDTO>();
Log.i("xxx", "getXML start!");
try {
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
XmlPullParser parser = factory.newPullParser();
parser.setInput(is, "utf-8");
int eventType = parser.getEventType();
EmpDTO dto = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
switch (eventType) {
case XmlPullParser.START_TAG:
String startTag = parser.getName();
if (startTag.equals("record")) {
dto = new EmpDTO();
}
if (dto != null) {
if (startTag.equals("loc")) {
dto.setLoc(parser.nextText());
}
} else {
Log.i("xxx", "dto = null");
}
break;
case XmlPullParser.END_TAG:
String endTag = parser.getName();
if (endTag.equals("record")) {
list.add(dto);
}
}
eventType = parser.next();
}
for (EmpDTO xx : list) {
Log.i("xxx", "" + xx.getLoc());
}
} catch (XmlPullParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException ie) {
// TODO Auto-generated catch block
ie.printStackTrace();
}
return list;
}
@Override
protected void onResume() {
super.onResume();
String requestURL = "http://192.168.123.000 :8181/Orginal/s2a11.jsp";
InputStream is = requestGet(requestURL);
final ArrayList<EmpDTO> list = getXML(is);
adapter = new CustomAdapter(getApplicationContext(), list,
R.layout.custom_list);
lv.setAdapter(adapter);
lv.setOnItemLongClickListener(new OnItemLongClickListener() {
@Override
public boolean onItemLongClick(AdapterView<?> parent, View view,
final int position, long id) {
AlertDialog diaBox = new AlertDialog.Builder(MainActivity.this)
.setTitle("삭제")
.setMessage("해당 조를 삭제하시겠습니까?")
.setPositiveButton("YES",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {
EmpDTO i = list.get(position);
adapter.deleteEmpDTO(i.getLoc());
lv.clearChoices();
adapter.notifyDataSetChanged();
}
}).setNegativeButton("NO", null).create();
diaBox.show();
return false;
public class CustomAdapter extends BaseAdapter {
Context ctx;
ArrayList<EmpDTO> list;
int layout;
LayoutInflater inf;
ListView lv;
CustomAdapter adapter;
public CustomAdapter(Context ctx, ArrayList<EmpDTO> list, int layout) {
super();
this.ctx = ctx;
this.list = list;
this.layout = layout;
inf = (LayoutInflater) ctx
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return list.get(position);
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
if (convertView == null) {
convertView = inf.inflate(layout, null);
}
TextView txt_loc = (TextView) convertView.findViewById(R.id.txt_loc);
txt_loc.setText("loc : " + list.get(position).getLoc());
return convertView;
}
public void deleteEmpDTO(String Loc) {
// TODO Auto-generated method stub
}
}
EmpDTO.java
public class EmpDTO {
private String loc;
public EmpDTO(String loc) {
super();
this.loc = loc;
}
public EmpDTO() {
super();
}
public void setLoc(String loc) {
this.loc = loc;
}
public String getLoc() {
return loc;
}
}