【发布时间】:2010-03-30 16:41:42
【问题描述】:
当我使用的静态 SQLite 数据库类中发生异常时,我想向用户显示一条消息(消息框或 Toast)。
问题是我不能在静态类中调用非静态方法,我该如何处理。
这是类
private static SQLiteDatabase getDatabase(Context aContext) {
并且我想在发生异常时在类中添加类似的内容,但context 会在静态类中生成对非静态的引用问题。
Context context = getApplicationContext();
CharSequence text = "Hello toast!";
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
【问题讨论】:
标签: java android exception-handling