源附件不包含的源文件SQLiteOpenHelper.class源文件、不包含、附件、class

2023-09-05 05:02:05 作者:痛彻心扉

我在Android版本4.2的样本应用程序。我已经设置的断点为每一条线路。在调试的时候,忽然调试停止说该人士附件不包含的源文件SQLiteOpenHelper.class。

I had a sample app in android version 4.2. I had set Breakpoints for each and every line. At the time of debugging, suddenly the debugging stopped saying that "The source attachment does not contain the source for the file SQLiteOpenHelper.class".

我重视的jar文件,它仍然报告错误。当前安装的一切。但不知道原因这个错误。

I attached the jar file and still it reports the error. Installed everything currently. But dont know the cause for this error.

这是我的MainActivity.java

This is my MainActivity.java

package com.example.newwaterreadingapp;


import java.util.Calendar;
import android.os.Bundle;
import android.app.Activity;
import android.content.ContentValues;
import android.database.sqlite.SQLiteDatabase;
import android.view.Menu;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;



public class MainActivity extends Activity {

protected static final android.content.Context Context = null;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);     
    setContentView(R.layout.activity_main);

    final RelativeLayout mainLayout=(RelativeLayout)findViewById(R.id.mainLayout);
    mainLayout.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
    final LinearLayout readingLayout=(LinearLayout)findViewById(R.id.waterReading);
    readingLayout.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
    final LinearLayout pastDatePickerLayout=(LinearLayout)findViewById(R.id.PastDatePickerLayout);
    pastDatePickerLayout.startAnimation(AnimationUtils.loadAnimation(this, android.R.anim.slide_out_right));
    readingLayout.setVisibility(View.GONE);
    pastDatePickerLayout.setVisibility(View.GONE);


    Button AddWaterReading=(Button)findViewById(R.id.AddWaterReading);    //click on + button.
    AddWaterReading.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            readingLayout.setVisibility(View.VISIBLE);
            mainLayout.setVisibility(View.GONE);
            TextView txtgetCurrentDate=(TextView)findViewById(R.id.currentDate);
            final Calendar c=Calendar.getInstance();
            txtgetCurrentDate.setText((c.get(Calendar.MONTH)+1)+"/"+c.get(Calendar.DATE)+"/"+c.get(Calendar.YEAR));  

        }
    });

    TextView getPastDate=(TextView)findViewById(R.id.getDate);
    getPastDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            readingLayout.setVisibility(View.GONE);
            pastDatePickerLayout.setVisibility(View.VISIBLE);                           
        }
    });

    Button savePastDate=(Button)findViewById(R.id.savePastDate);
    savePastDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            pastDatePickerLayout.setVisibility(View.GONE);
            readingLayout.setVisibility(View.VISIBLE);

            DatePicker getPastDatepicker=(DatePicker)findViewById(R.id.getPastDate);
                int YY=getPastDatepicker.getYear();
                int MM=getPastDatepicker.getMonth();
                int DD=getPastDatepicker.getDayOfMonth();
                TextView getPastDate=(TextView)findViewById(R.id.getDate);  
                getPastDate.setText((MM+1)+"/"+DD+"/"+YY);
        }
    });


    Button saveWaterReadingToDB=(Button)findViewById(R.id.saveWaterReading);
    saveWaterReadingToDB.setOnClickListener(new View.OnClickListener() {


        @Override
        public void onClick(View v) {
            readingLayout.setVisibility(View.GONE);
             mainLayout.setVisibility(View.VISIBLE);    

             TextView getPastDate=(TextView)findViewById(R.id.getDate);
             TextView txtgetCurrentDate=(TextView)findViewById(R.id.currentDate);
             TextView txtgetWaterReading=(TextView)findViewById(R.id.water_Reading);


             CreateDB helper =new CreateDB(Context, "WaterElectricityReading.db", null, 1);              

             SQLiteDatabase DB;

             DB=helper.getWritableDatabase();

             String pastDate=getPastDate.getText().toString().trim();
             String currentDate=txtgetCurrentDate.getText().toString().trim();
             String waterReading=txtgetWaterReading.getText().toString().trim();


             ContentValues values=new ContentValues();
             values.put(CreateDB.COLUMN_NAME_READING_MODE,"Water");
             values.put(CreateDB.COLUMN_NAME_PASTDATETIME, pastDate);
             values.put(CreateDB.COLUMN_NAME_CURRENTDATETIME, currentDate);
             values.put(CreateDB.COLUMN_NAME_READINGVALUE, waterReading);

             DB.insert(CreateDB.TABLE_NAME, null, values);
             Toast.makeText(getApplicationContext(), "Added", Toast.LENGTH_LONG).show();
             DB.close();
             helper.close();                 
        }
    });

}


@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.activity_main, menu);
    return true;
}

}

和CreateDB.java

and CreateDB.java

package com.example.newwaterreadingapp;


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;



public class CreateDB extends SQLiteOpenHelper{

    private static final String DATABASE_NAME="WaterElectricityReading.db";
    public static final String TABLE_NAME="Reading";
    public static final String COLUMN_NAME_READING_ID="_Id";
    public static final String COLUMN_NAME_READING_MODE="ReadingMode";
    public static final String COLUMN_NAME_PASTDATETIME="PastDateTime";
    public static final String COLUMN_NAME_CURRENTDATETIME="CurrentDateTime";
    public static final String COLUMN_NAME_READINGVALUE="ReadingValue";
    public static final int DATABASE_VERSION = 1;
     public static String DB_PATH = "";


    public CreateDB(Context context,String name, CursorFactory factory,
            int version) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);                                  
    }

    public void onCreate(SQLiteDatabase DB){

        final String CREATE_TABLE="create table if not exists "+ TABLE_NAME + "("+ COLUMN_NAME_READING_ID +" integer primary key autoincrement,"
                +COLUMN_NAME_READING_MODE+" text not null,"+COLUMN_NAME_PASTDATETIME+" date not null,"+COLUMN_NAME_CURRENTDATETIME
                +" date not null,"+COLUMN_NAME_READINGVALUE+" integer not null"+");";
        DB.execSQL(CREATE_TABLE);                                                       

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
        // TODO Auto-generated method stub

    }           

}

任何人都可以请建议我哪里错了。

Could anyone please suggest where I went wrong.

感谢。

推荐答案

一个的.jar本身并不公开其源$ C ​​$ C。你必须自己添加源$ C ​​$ C才能浏览它。

A .jar does not expose its source code by itself. You'll have to add the source code by yourself to be able to browse it.

您可以pretty的肯定,虽然这个错误会在你自己的一方,所以你可能会问,使用Android的调试code :)

You can be pretty sure though that the mistake will be on your own side, so you could question the use of debugging Android code :)

您可以手动添加它(不记得如何,谷歌),或者使用一个Eclipse插件,这在以往的工作做得很好,我; 的https://$c$c.google.com/p/adt-addons/ 可能有点过时,但。

You can add it manually (don't remember how, Google) or use an Eclipse plugin which did a good job for me in the past; https://code.google.com/p/adt-addons/ Might be a little out-dated though.