您好我正在为我的应用程序使用Stetho调试平台.我已经在我的gradle中添加了Stetho,如下所示
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.facebook.stetho:stetho:1.2.0'
}
并将其初始化为onCreate方法,如下所示
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Stetho.initializeWithDefaults(this); findElementsByIds(); addDataIntoDBs(); initData(); }
我已经为demo创建了Category表(作为cat_id和cat_name列)并在其中添加了一些条目,请参阅 此截图.
任何人都可以告诉它为什么显示两个与图像中名称相同的列
我为表创建所做的代码
public class DBHelper extends SQLiteOpenHelper{ private static String DATABASE_NAME = "citizan.db"; private static int DATABASE_VERSION = 1; private static DBHelper dbHelperInstance = null; private static SQLiteDatabase dbInstance= null; public static String CATEGORY_TABLE = "category"; public static String CAT_ID = "cat_id"; public static String CAT_NAME = "cat_name"; private String CREATE_CATEGORY_TABLE = "create table "+CATEGORY_TABLE + "("+CAT_ID+" Integer primary key autoincrement, " +CAT_NAME+ " text"+")"; private String DROP_CATEGORY_TABLE = "drop table if exists "+CATEGORY_TABLE; private DBHelper(Context context) { super(context, AppConstants.DATABASE_NAME, null,AppConstants.DATABASE_VERSION); } public static synchronized DBHelper getInstance(Context context) { if(dbHelperInstance == null) { dbHelperInstance = new DBHelper(context); } return dbHelperInstance; } @Override public void onCreate(SQLiteDatabase db) { db.execSQL(CREATE_CATEGORY_TABLE); } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { db.execSQL(DROP_CATEGORY_TABLE); onCreate(db); } public static void openConnection() { if(dbInstance == null) { dbInstance = dbHelperInstance.getWritableDatabase(); } } public void addCategories(String[] catArray) { openConnection(); ContentValues values = new ContentValues(); for (int i=0;i}