0

我在我的Android应用程序中遇到了这个问题...

当用户尝试登录时,我首先使用我的 DataBaseHelper 类在本地 SQLite 数据库中查找他的用户名和密码......如果它不存在,那么我创建一个 Http 连接(使用我的 HttpPostAux 类)来验证用户名和密码以及存储在服务器中央 PostgreSQL 数据库中的数据...

我在 LogCat 中收到此错误:

10-15 10:07:13.781: E/Cursor(3855): Invalid statement in fillWindow()
10-15 10:07:13.781: E/itemCursor(3855): vacio
10-15 10:07:13.859: D/dalvikvm(3855): GC_EXTERNAL_ALLOC freed 118K, 48% free 2845K/5379K, external 2643K/2652K, paused 27ms
10-15 10:07:13.867: D/Cursor(3855): Database path: /data/data/tian.proto/databases/PROTOTIPO
10-15 10:07:13.867: D/Cursor(3855): Table name   : null
10-15 10:07:13.867: D/Cursor(3855): SQL          : SQLiteQuery: SELECT * FROM usuario
10-15 10:07:13.867: I/dalvikvm(3855): Uncaught exception thrown by finalizer (will be discarded):
10-15 10:07:13.867: I/dalvikvm(3855): Ljava/lang/IllegalStateException;: Finalizing cursor android.database.sqlite.SQLiteCursor@4053c2f0 on null that has not been deactivated or closed
10-15 10:07:13.867: I/dalvikvm(3855):   at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:620)
10-15 10:07:13.867: I/dalvikvm(3855):   at dalvik.system.NativeStart.run(Native Method)
10-15 10:07:13.898: E/log_tag(3855): se conecto bien 1
10-15 10:07:13.898: E/log_tag(3855): se conecto bien
10-15 10:07:14.328: E/is(3855): org.apache.http.conn.EofSensorInputStream@4056ecc8
10-15 10:07:14.328: E/log_tag(3855): se conecto bien
10-15 10:07:14.343: E/getPostResponse(3855): result= 
10-15 10:07:14.343: E/getPostResponse(3855): [{"logstatus":"1"}]
10-15 10:07:14.343: E/log_tag(3855): respondio bien
10-15 10:07:15.296: E/loginStatus(3855): logstatus = 1
10-15 10:07:15.296: E/loginStatus(3855): válido
10-15 10:07:15.296: E/onPostExecute=(3855): ok
10-15 10:07:15.304: E/initialvalues=(3855): nombre=alois.wirkes contrasena=qwerty
10-15 10:07:15.421: D/AndroidRuntime(3855): Shutting down VM
10-15 10:07:15.421: W/dalvikvm(3855): threadid=1: thread exiting with uncaught exception (group=0x40015578)
10-15 10:07:15.429: E/AndroidRuntime(3855): FATAL EXCEPTION: main
10-15 10:07:15.429: E/AndroidRuntime(3855): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = tian.proto.lib.DataBaseHelper)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Parcel.writeSerializable(Parcel.java:1176)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Parcel.writeValue(Parcel.java:1130)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Parcel.writeMapInternal(Parcel.java:488)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Bundle.writeToParcel(Bundle.java:1552)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Parcel.writeBundle(Parcel.java:502)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.content.Intent.writeToParcel(Intent.java:5623)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1341)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1374)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.app.Activity.startActivityForResult(Activity.java:2827)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.app.Activity.startActivity(Activity.java:2933)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at tian.proto.Main$asyncLogin.onPostExecute(Main.java:206)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at tian.proto.Main$asyncLogin.onPostExecute(Main.java:1)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.AsyncTask.finish(AsyncTask.java:417)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.AsyncTask.access$300(AsyncTask.java:127)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:429)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Looper.loop(Looper.java:130)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.app.ActivityThread.main(ActivityThread.java:3687)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.lang.reflect.Method.invokeNative(Native Method)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.lang.reflect.Method.invoke(Method.java:507)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:842)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at dalvik.system.NativeStart.main(Native Method)
10-15 10:07:15.429: E/AndroidRuntime(3855): Caused by: java.io.NotSerializableException: tian.proto.Main
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1535)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1143)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:413)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1241)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1575)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1847)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1689)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1653)
10-15 10:07:15.429: E/AndroidRuntime(3855):     at android.os.Parcel.writeSerializable(Parcel.java:1171)
10-15 10:07:15.429: E/AndroidRuntime(3855):     ... 22 more

我想这与我的 DataBaseHelper 对象有关,因为当我这样做时:

public static DataBaseHelper mDbHelper = new DataBaseHelper(this);

数据库是空的,所以当我尝试在本地验证用户时:

protected boolean foundInDB(String usuario, String contrasena) {
        // TODO Auto-generated method stub
        mDbHelper.open();
        Cursor itemCursor = null;
        itemCursor = mDbHelper.getItemsUser();
        mDbHelper.close();

        if(itemCursor.moveToFirst() == false){
            Log.e("itemCursor","vacio");
            return false;
        }

        int nameColumnIndex1 = itemCursor.getColumnIndex(DataBaseHelper.SL_USER_NOMBRE);
        int nameColumnIndex2 = itemCursor.getColumnIndex(DataBaseHelper.SL_USER_CONTRASENA);

        for(itemCursor.moveToFirst();!itemCursor.isAfterLast();itemCursor.moveToNext()){
            String name = itemCursor.getString(nameColumnIndex1);
            String pass = itemCursor.getString(nameColumnIndex2);
            if(name.equals(usuario) && pass.equals(contrasena)){
                return true;    
            }
        }
        return false;
    }

我认为 LogCat 中出现了第 3 到 10 行......我认为其余的错误也是由于我的 DataBaseHelper 类,因为它实现了可序列化......

public class DataBaseHelper implements Serializable{
    ...
}

所以我可以将我的主要活动中声明的引用传递给其他活动,这样我就可以操作本地数据库......

Intent intent = new Intent(Main.this,pantalla2.class);
intent.putExtra("NOMBRE", usuario);
intent.putExtra("CONTRASENA", contrasena);
intent.putExtra("DATABASE", mDbHelper);
startActivity(intent);

关于如何解决这个问题的任何想法?顺便问一下,LogCat 的第一行(fillWindow() 中的无效语句)是什么意思?

4

0 回答 0