Tonio’s code for creating db on android stuff


package marvin.pack;

import android.app.Activity;

public class marvin2 extends Activity
{
protected void onCreate(Bundle icicle)
{
super.onCreate(icicle);
//setContentView(new GLView(getApplication()));
setContentView(R.layout.main);
TextView tv = (TextView) findViewById(R.id.text);
try
{
SQLiteDatabase db = createDatabase(“test”, 1, MODE_PRIVATE, null);
db.execSQL(“CREATE TABLE IF NOT EXISTS table1 (champ1 INTEGER)”);
SQLiteCursor cursor = (SQLiteCursor) db.query(“SELECT * FROM sqlite_master”, null);

String test = “Structure :\n”;
for(int i = 0 ; i < cursor.getColumnNames().length ; ++i)
{
test += cursor.getColumnNames()[i] + ” ; “;
}
test += “\n”;
while(cursor.next())
{
for( int i = 0 ; i < cursor.getColumnNames().length ; ++i)
{
test += cursor.getString(i) + ” ; “;
}
test += “\n”;
}

tv.setText(test);

db.close();
}
catch(Exception e) {tv.setText(e.toString());}
}

protected void onResume()
{
super.onResume();
}

protected void onStop()
{
super.onStop();
}
}

Comments are closed.