解决方案 »
- android自适应分辨率,希望一个layout就能通用
- 我做了个android视频监控传输程序,运行了一会儿死机了,怎么样才能找到问题所在?
- 求助(Conversion to Dalvik format failed with error 1 )
- 求助:基于android系统的问卷调查系统的
- PC跟手机用蓝牙通信,实现远程命令控制电脑,可行性如何,难度大不?
- setImageDrawable设置多张图片的问题
- 如何在launcher2中启动一个自己的activity?
- webview下载文件的下载进度怎么显示
- Unexpected response code 500 for
- 安卓开发报错 Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUN
- Activity怎么更新fragment的UI界面?
- 新手写一个闹钟app遇到了问题。。求大神!!
public class AddressDao {
public static final String path = "/data/data/com.zhong.mobilesafe/files/address.db";
/**
* 获取手机号码的归属地
*
* @param number
* 传入的手机号码
* @return 归属地
*/
public static String getAddress(String number) {
String address = number;
SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null,
SQLiteDatabase.OPEN_READONLY);
if (number.matches("^1[3458]\\d{9}$")) {
Cursor cursor = db
.rawQuery(
"select location from data2 where id=(select outkey from data1 where id=?)",
new String[] { number.substring(0, 7) }); if (cursor.moveToNext()) {
address = cursor.getString(0);
}
cursor.close();
}
db.close();
return address;
还是不太明白怎么用,下面贴上具体代码
public class AddressDao {
public static final String path = "/data/data/com.zhong.mobilesafe/files/address.db";
/**
* 获取手机号码的归属地
*
* @param number
* 传入的手机号码
* @return 归属地
*/
public static String getAddress(String number) {
String address = number;
SQLiteDatabase db = SQLiteDatabase.openDatabase(path, null,
SQLiteDatabase.OPEN_READONLY);
if (number.matches("^1[3458]\\d{9}$")) {
Cursor cursor = db
.rawQuery(
"select location from data2 where id=(select outkey from data1 where id=?)",
new String[] { number.substring(0, 7) }); if (cursor.moveToNext()) {
address = cursor.getString(0);
}
cursor.close();
}
db.close();
return address;
pubic AddressDao (Context context)
{
this.context = context;
}然后在调用的时候获取
context.getFilesDir().getPath()获取路径。