解决方案 »

  1.   

    getFilesDir是对象方法不是类方法,所以调用必须使用Context实例,如果在android组件中可以使用getApplicationContext()来获取context对象.
      

  2.   

    还是不太明白怎么用,下面贴上具体代码
    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;
      

  3.   

    我建议你先学习一下java基础,如果不学好的话,可能学习android也会比较吃力.你可以看一下Thinking In Java中文版.
    还是不太明白怎么用,下面贴上具体代码
    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;
      

  4.   

    将类AddressDao 的构造函数修改为
    pubic AddressDao (Context context)
    {
               this.context = context;
    }然后在调用的时候获取
    context.getFilesDir().getPath()获取路径。