Hello I am using Stetho debugging platform for my application. I have added Stetho in my gradle as follows
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'
}
and initialized it into onCreate method as follows
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Stetho.initializeWithDefaults(this);
findElementsByIds();
addDataIntoDBs();
initData();
}
I have created Category table (as cat_id and cat_name columns) for demo and added some entries into it, please see this screenshot.
Can anyone tell why it is showing two columns with same name as in the image
code which I have done for table creation
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<catArray.length;i++)
{
values.put(CAT_NAME, catArray[i]);
dbInstance.insert(CATEGORY_TABLE,null,values);
}
}
}
来源:https://stackoverflow.com/questions/34311348/stetho-showing-two-columns-with-same-name