应用程序不适用于 android 4.4.4 和 5.1.1,但适用于 4.0.3 和模拟器

Application doesn't work on android 4.4.4 and 5.1.1, but works on 4.0.3 and emulators

我正在尝试 运行 我的 phone 我的应用程序。但是当我在应用程序中转到 activity 时,它就崩溃了。但它在 4.0.3 和模拟器上运行完美。我应该怎么办? + 我只是将 app_debug.apk 文件发送到我的 phone 并使用 phone 安装,而不是 android studio,因为 AS 没有看到我的设备

private static final int CM_DELETE_ID = 1;
ListView lvData;
DB2 db;
SimpleCursorAdapter scAdapter;
Cursor cursor;
Button bt;
SharedPreferences bh;
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_test4);
    bt = (Button)findViewById(R.id.button);
    bh = getSharedPreferences("O", Context.MODE_PRIVATE);
    db = new DB2(this);
    db.open();
    cursor = db.getAllData();
    startManagingCursor(cursor);
    String[] from = new String[] { DB2.COLUMN_IMG, DB2.COLUMN_TXT, DB2.COLUMN_DAY, DB2.COLUMN_MONTH,DB2.COLUMN_YEAR,DB2.COLUMN_HOUR,DB2.COLUMN_MINUTE};
    int[] to = new int[] { R.id.ivImg, R.id.tvText, R.id.tvNmb, R.id.monthDB,R.id.yearDB };
    scAdapter = new SimpleCursorAdapter(this, R.layout.item, cursor, from, to);
    lvData = (ListView) findViewById(R.id.lvData);
    lvData.setAdapter(scAdapter);

    registerForContextMenu(lvData);

    lvData.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                                long id) {
            Bundle bundle = new Bundle();
            bundle.putString("name", cursor.getString(cursor.getColumnIndex(DB2.COLUMN_TXT)));
            bundle.putString("day", cursor.getString(cursor.getColumnIndex(DB2.COLUMN_DAY)));
            bundle.putString("month", cursor.getString(cursor.getColumnIndex(DB2.COLUMN_MONTH)));
            bundle.putString("year",cursor.getString(cursor.getColumnIndex(DB2.COLUMN_YEAR)));
            bundle.putString("hour",cursor.getString(cursor.getColumnIndex(DB2.COLUMN_HOUR)));
            bundle.putString("minute",cursor.getString(cursor.getColumnIndex(DB2.COLUMN_MINUTE)));
            Intent intent = new Intent(TEST4.this,TEST6.class);
            intent.putExtras(bundle);
            startActivity(intent);
        }
    });

    lvData.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        public void onItemSelected(AdapterView parentView, View childView,
                                   int position, long id) {
            setContentView(R.layout.item);
        }

        public void onNothingSelected(AdapterView parentView) {

        }
    });

}

private void buttonClick()
{
    startActivity(new Intent("com.example.dc2.TEST5"));
}

public void onButtonClick(View view) {
    switch(view.getId())
    {
        case R.id.button: {
            buttonClick();
            break;
        }
    }
}

public void onCreateContextMenu(ContextMenu menu, View v,
                                ContextMenu.ContextMenuInfo menuInfo) {
    super.onCreateContextMenu(menu, v, menuInfo);
    menu.add(0, CM_DELETE_ID, 0, R.string.delete_record);
}


public boolean onContextItemSelected(MenuItem item) {
    if (item.getItemId() == CM_DELETE_ID) {
        AdapterView.AdapterContextMenuInfo acmi = (AdapterView.AdapterContextMenuInfo) item.getMenuInfo();
        db.delRec(acmi.id);
        // обновляем курсор
        cursor.requery();
        return true;
    }
    return super.onContextItemSelected(item);
}

protected void onDestroy() {
    super.onDestroy();
    db.close();
}

这是我的logcat

10-05 20:19:33.933  13324-13324/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.dc2, PID: 13324
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dc2/com.example.dc2.TEST4}: android.database.sqlite.SQLiteException: near ")": syntax error (code 1): , while compiling: create table mytab(_id integer primary key autoincrement, img integer, txt text, day day, month month, year year, hour hour, minute minute, );

我的数据库代码

private static final String DB_NAME = "mydb";
private static final int DB_VERSION = 2200;
private static final String DB_TABLE = "mytab";

public static final String COLUMN_ID = "_id";
public static final String COLUMN_IMG = "img";
public static final String COLUMN_TXT = "txt";
public static final String COLUMN_DAY = "day";
public static final String COLUMN_MONTH = "month";
public static final String COLUMN_YEAR = "year";
public static final String COLUMN_HOUR = "hour";
public static final String COLUMN_MINUTE = "minute";

private static final String DB_CREATE =
        "create table " + DB_TABLE + "(" +
                COLUMN_ID + " integer primary key autoincrement, " +
                COLUMN_IMG + " integer, " +
                COLUMN_TXT + " text, " +
                COLUMN_DAY + " day, " +
                COLUMN_MONTH + " month, " +
                COLUMN_YEAR + " year, " +
                COLUMN_HOUR + " hour, " +
                COLUMN_MINUTE + " minute, " +
                ");";

private final Context mCtx;


private DBHelper mDBHelper;
private SQLiteDatabase mDB1;

public DB2(Context ctx) {
    mCtx = ctx;
}

public void open() {
    mDBHelper = new DBHelper(mCtx, DB_NAME, null, DB_VERSION);
    mDB1 = mDBHelper.getWritableDatabase();
}

public void close() {
    if (mDBHelper!=null) mDBHelper.close();
}
public Cursor getAllData() {
    String[] columns = {"_id","txt","img","day","month","year","hour","minute"};
    return mDB1.query(DB_TABLE, columns, null, null, null, null, null);
}
public void addRec(String txt, int img, int day,int month, int year,int hour, int minute) {
    ContentValues cv = new ContentValues();
    cv.put(COLUMN_TXT, txt);
    cv.put(COLUMN_IMG, img);
    cv.put(COLUMN_DAY, day);
    cv.put(COLUMN_MONTH,month);
    cv.put(COLUMN_YEAR,year);
    cv.put(COLUMN_HOUR,hour);
    cv.put(COLUMN_MINUTE,minute);
    mDB1.insert(DB_TABLE, null, cv);
}
public void delRec(long id) {
    mDB1.delete(DB_TABLE, COLUMN_ID + " = " + id, null);
}

private class DBHelper extends SQLiteOpenHelper {

    public DBHelper(Context context, String name, SQLiteDatabase.CursorFactory factory,
                    int version) {
        super(context, name, factory, version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(DB_CREATE);

    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    }
}
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="abc.abc" android:versionCode="1" android:versionName="1.0" android:installLocation="auto">
    <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
    <application android:label="abc" android:icon="@drawable/Icon"></application>
</manifest>

使用 android:targetSdkVersion="22" for android 5.1.1 在 androidmanifest.xml 文件.

我找到了答案...在我的数据库代码中

private static final String DB_CREATE =
    "create table " + DB_TABLE + "(" +
            COLUMN_ID + " integer primary key autoincrement, " +
            COLUMN_IMG + " integer, " +
            COLUMN_TXT + " text, " +
            COLUMN_DAY + " day, " +
            COLUMN_MONTH + " month, " +
            COLUMN_YEAR + " year, " +
            COLUMN_HOUR + " hour, " +
            COLUMN_MINUTE + " minute, " +
            ");";

在");"之前"minute"之后不应该有逗号")";"