我知道如何做 SQLite 数据库,特别是在它自己的专用 java 类中。但是每当我希望它位于某个东西的内部时,在这种情况下,它是一个 Intent 服务,它总是给我错误,我无法调试它。
package my.skul;
import android.app.IntentService;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
public class CheckClassroom extends IntentService {
/**
* A constructor is required, and must call the super IntentService(String)
* constructor with a name for the worker thread.
*/
public CheckClassroom() {
super("CheckClassroom");
}
/**
* The IntentService calls this method from the default worker thread with
* the intent that started the service. When this method returns,
* IntentService stops the service, as appropriate.
*/
@Override
protected void onHandleIntent(Intent intent) {
}
private DbHelper ourHelper;
private final Context ourContext;
private SQLiteDatabase ourDatabase;
private static class DbHelper extends SQLiteOpenHelper {
public DbHelper(Context context) {
super(context, "myschool", null, 1);
// TODO Auto-generated constructor stub
}
@Override
public void onCreate(SQLiteDatabase arg0) {
// TODO Auto-generated method stub
}
@Override
public void onUpgrade(SQLiteDatabase arg0, int arg1, int arg2) {
// TODO Auto-generated method stub
}
public CheckClassroom(Context c) {
ourContext = c;
}
public CheckClassroom open() {
ourHelper = new DbHelper(ourContext);
ourDatabase = ourHelper.getWritableDatabase();
return this;
}
public void close() {
ourHelper.close();
}
}
getColumns()
{
//retrieve sqlitedatabase data
}
}
我一直在阅读很多关于构造函数的内容,但我并不能完全理解它,在这里解释我所有的错误真的会让我更好地理解这一点。谢谢..