Solution Arabic text in SQLite
Solution to this problem is keeping the data through the Arab command (must be Insert Data by code (Insert into Table_name ( )Values( ))don't insert data on SQlite direct this for Arabic but English no problem )
public class SQLiteAdapter
public static final String MYDATABASE_NAME = "TestSQLilte.s3db";
@SuppressLint("SdCardPath")
// Do not forget This code DB_DIR Because the program does not work on Mobile without this code
private static String DB_DIR = "/data/data/PackageName/databases/";
@SuppressWarnings("unused")
// Do not forget This code DB_DIR Because the program does not work on Mobile without this code
private static String DB_PATH = DB_DIR + MYDATABASE_NAME;
public static final String MYDATABASE_TABLE = "Table_Name";
public static final int MYDATABASE_VERSION = 2;
public static final String KEY_ID = "_id";
public static final String KEY_Name = "Name";
public static final String KEY_Adress = "Address";
public static final String KEY_Area = "Phone";
private static final String SCRIPT_CREATE_DATABASE =
"create table IF NOT EXISTS " + MYDATABASE_TABLE + " ("
+ KEY_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, "
+ KEY_Name + " Text not null"
+ ", "
+ KEY_Adress + " Text not null"
+ ", "
+ KEY_Phone + " Text not null);";
private Context context;
public SQLiteAdapter(Context c){
context = c;
}
// Do not forget This code DB_DIR Because the program does not work on Mobile without this code
public SQLiteAdapter openToRead() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
DB_PATH = context.getDatabasePath(MYDATABASE_NAME).getAbsolutePath();
sqLiteDatabase = sqLiteHelper.getReadableDatabase();
return this;
}
// Do not forget This code DB_DIR Because the program does not work on Mobile without this code
public SQLiteAdapter openToWrite() throws android.database.SQLException {
sqLiteHelper = new SQLiteHelper(context, MYDATABASE_NAME, null, MYDATABASE_VERSION);
DB_PATH = context.getDatabasePath(MYDATABASE_NAME).getAbsolutePath();
sqLiteDatabase = sqLiteHelper.getWritableDatabase();
return this;
}
// Do not forget This code mySQLiteAdapter.insert Because the program does not Display arabic without this code
public long insert(String Name,String Adress,String Phone){
ContentValues contentValues = new ContentValues();
contentValues.put(KEY_About_Content, Name);
contentValues.put(KEY_Adress,Adress);
contentValues.put(KEY_Area ,Area);
return sqLiteDatabase.insert(MYDATABASE_TABLE, null, contentValues);
}
public class MainActivity
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.Test);
mySQLiteAdapter = new SQLiteAdapter(this);
mySQLiteAdapter.openToWrite();
// Do not forget This code mySQLiteAdapter.insert Because the program does not Display arabic without this code
mySQLiteAdapter.insert ("1الاسم","العنوان","التلفون");
mySQLiteAdapter.insert ("2الاسم","العنوان","التلفون");
mySQLiteAdapter.insert ("3الاسم","العنوان","التلفون");
mySQLiteAdapter.insert ("4الاسم","العنوان","التلفون");
}
I've been suffering from this problem, thank God, it has been resolved in this wa