Android APP 多语言 SQLite
Android APP multilanguage SQLite
我会完整翻译我的 Android 应用程序。 (这包括 SQLite 在 phone 语言上显示)
这就像现在连接;
private static final int DATABASE_VERSION = 5;
private static final String DATABASE_NAME = "quotes.db";
private static final String DB_PATH_SUFFIX = "/databases/";
private static final String TABLE_QUOTES = "quote";
private static final String KEY_ID = "_id";
static Context myContext;
public DataBaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
myContext = context;
}
我曾想删除名称字符串数据库并使用 strings.xml 文件将名称数据库传递给它。
super(context, context.getResources().getString(R.string.DATABASE_NAME), null, DATABASE_VERSION);
也寻找通过strings.xml传递的查询,但找不到明确的文档。
不多多指点一下,不胜感激。非常感谢。
查询示例:
// Select All Query
String selectQuery = "SELECT name, COUNT(author_name ) AS count FROM author LEFT JOIN quote ON name = author_name WHERE name LIKE '%"
+ value + "%' GROUP BY name ORDER BY name ASC";
我修改 table sqlite 和代码添加“+Locale.getDefault().getLanguage() +”:
String selectQuery = "SELECT quote._id, quote.author_name_"+ Locale.getDefault().getLanguage() +", quote.qte_"+ Locale.getDefault().getLanguage() +
", quote.category_name_"+ Locale.getDefault().getLanguage() +",fav FROM quote,author where author.name_"+ Locale.getDefault().getLanguage()+
" = quote.author_name_"+ Locale.getDefault().getLanguage() +" and quote.category_name_"+ Locale.getDefault().getLanguage() +
"!='Tips Romanticos' ORDER BY quote.author_name_"+ Locale.getDefault().getLanguage() +" "+limit;
查询结果为:
SELECT quote._id, quote.author_name_es, quote.qte_es,
quote.category_name_es,fav FROM quote,author where author.name_es =
quote.author_name_es and quote.category_name_es!='Tips Romanticos'
ORDER BY quote.author_name_es LIMIT 50
我会完整翻译我的 Android 应用程序。 (这包括 SQLite 在 phone 语言上显示)
这就像现在连接;
private static final int DATABASE_VERSION = 5;
private static final String DATABASE_NAME = "quotes.db";
private static final String DB_PATH_SUFFIX = "/databases/";
private static final String TABLE_QUOTES = "quote";
private static final String KEY_ID = "_id";
static Context myContext;
public DataBaseHandler(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
myContext = context;
}
我曾想删除名称字符串数据库并使用 strings.xml 文件将名称数据库传递给它。
super(context, context.getResources().getString(R.string.DATABASE_NAME), null, DATABASE_VERSION);
也寻找通过strings.xml传递的查询,但找不到明确的文档。
不多多指点一下,不胜感激。非常感谢。
查询示例:
// Select All Query
String selectQuery = "SELECT name, COUNT(author_name ) AS count FROM author LEFT JOIN quote ON name = author_name WHERE name LIKE '%"
+ value + "%' GROUP BY name ORDER BY name ASC";
我修改 table sqlite 和代码添加“+Locale.getDefault().getLanguage() +”:
String selectQuery = "SELECT quote._id, quote.author_name_"+ Locale.getDefault().getLanguage() +", quote.qte_"+ Locale.getDefault().getLanguage() +
", quote.category_name_"+ Locale.getDefault().getLanguage() +",fav FROM quote,author where author.name_"+ Locale.getDefault().getLanguage()+
" = quote.author_name_"+ Locale.getDefault().getLanguage() +" and quote.category_name_"+ Locale.getDefault().getLanguage() +
"!='Tips Romanticos' ORDER BY quote.author_name_"+ Locale.getDefault().getLanguage() +" "+limit;
查询结果为:
SELECT quote._id, quote.author_name_es, quote.qte_es, quote.category_name_es,fav FROM quote,author where author.name_es = quote.author_name_es and quote.category_name_es!='Tips Romanticos' ORDER BY quote.author_name_es LIMIT 50