SQLiteDatabase
在DDMS的File Explorer中的data\data\PACKAGE_NAME\databases中可以看到数据库的创建和删除
public class MainActivity extends Activity implements OnClickListener { public static final String DATABASE_NAME = "mdb"; private SQLiteDatabase database; private Button bt1, bt2, bt3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); bt1 = (Button) findViewById(R.id.button1); bt2 = (Button) findViewById(R.id.button2); bt3 = (Button) findViewById(R.id.button3); bt1.setOnClickListener(this); bt2.setOnClickListener(this); bt3.setOnClickListener(this); } @Override public void onClick(View v) { // TODO Auto-generated method stub switch (v.getId()) { case R.id.button1: database = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null); if (database != null) { Toast.makeText(getBaseContext(), getString(R.string.create_success) + DATABASE_NAME, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getBaseContext(), getString(R.string.create_failure) + DATABASE_NAME, Toast.LENGTH_LONG).show(); } break; case R.id.button2: database.close(); Toast.makeText(getBaseContext(), getString(R.string.close_success) + DATABASE_NAME, Toast.LENGTH_LONG).show(); break; case R.id.button3: Boolean isDeleted = deleteDatabase(DATABASE_NAME); if (isDeleted) { Toast.makeText(getBaseContext(), getString(R.string.delete_success) + DATABASE_NAME, Toast.LENGTH_LONG).show(); } else { Toast.makeText(getBaseContext(), getString(R.string.delete_failure) + DATABASE_NAME, Toast.LENGTH_LONG).show(); } break; } } }