我正在开发一个同时支持英语和土耳其语的android应用程序。
应用程序包含一个sqlite数据库,其中包含一个表和autoincrement\u id列。
当这个应用程序在英文设备上运行时,它运行得很好,但是当它在土耳其设备上运行时,数据库将停止自动生成id。
我试图提取数据库文件并在sqlite数据库浏览器上打开它,它正在正确保存所有列的值,在土耳其语言环境中只有id列的值仍然为空
解决这个问题的办法?
编辑:
正在创建数据库:

public class DatabaseHandler extends SQLiteOpenHelper {
    private final static String TAG = "DatabaseHandler";

    private final static int DATABASE_VERSION = 3;
    private final static String DATABASE_NAME = "app_main_database";

    public DatabaseHandler(Context context) {
        super(context, DATABASE_NAME, null, DATABASE_VERSION);
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        String query = "CREATE TABLE tbl_item (_id INTEGER PRIMARY KEY NULL, _serverId TEXT NULL, _itemName TEXT NULL, _lastEditDate DATETIME NOT NULL)";

        db.execSQL(query);
    }

将行插入表:
    @Override
    public void insert() {
        ContentValues reVal = new ContentValues();

        reVal.put(COL_ITEM_SERVER_ID, getItemServerId());
        reVal.put(COL_ITEM_NAME, getItemName());
        reVal.put(COL_LAST_EDIT_DATE, getLastEditDate());

        SQLiteDatabase sqLite = new DatabaseHandler(this).getWritableDatabase();
        sqLite.insert(tableName, null, obj.getContentValues());
    }

最佳答案

您可以尝试打开数据库并将locale(使用setLocale)设置为english。默认情况下,它将使用系统区域设置。
使用openDatabase您也可以设置NO_LOCALIZED_COLLATORS标志(这将禁用每个setlocale并可以解决您的问题(但从未测试过它,只是目前的一些研究)

public static final int NO_LOCALIZED_COLLATORS

Added in API level 1
Open flag: Flag for openDatabase(String, SQLiteDatabase.CursorFactory, int) to open the database without support for localized collators.

This causes the collator LOCALIZED not to be created. You must be consistent when using this flag to use the setting the database was created with. If this is set, setLocale(Locale) will do nothing.

Constant Value: 16 (0x00000010)

作为第一次尝试,我将在setLocale对象上测试datatabase

07-28 14:00