Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
ISIKAN NAMANYA
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
}
public void close ()
{
this.DB.close();
}
private void createTable(SQLiteDatabase db2)
{
// TODO Auto-generated method stub
String sql = "CREATE TABLE IF NOT EXISTS person "
+ "(id INTEGER PRIMARY KEY, name TEXT)";
db2.execSQL(sql);
}
public long insertData (int id, String name)
{
ContentValues values = new ContentValues();
values.put("name", name);
return DB.insert("person", null, values);
}
public int updateData(int id, String name)
{
ContentValues values = new ContentValues();
values.put("name", name);
return DB.update("person", values, "id = "+id, null);
}
public int deleteData (int id)
{
return DB.delete("person", "id = " +id, null);
}
public ArrayList<String> getPersonList()
{
Cursor cursor = DB.rawQuery("SELECT * from person", null);
ArrayList<String> list = new ArrayList<String>();
cursor.moveToFirst();
for (int i = 0; i<cursor.getCount();i++ )
{
list.add(cursor.getString(cursor.getColumnIndex("name")));
cursor.moveToNext();
}
return list;
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
77.
78.
79. }
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70. }
data.close();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1,listdata);
ListView listView = (ListView) findViewById(R.id.listViewTampilData);
listView.setAdapter(adapter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}