Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 灌水乐园  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 暫時放一放2
David_Zhuo





发贴: 16
于 2012-02-22 16:54 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
String DB_PATH = "/data/data/com.mycompany.worldclock/databases/";
      String dbName = "world_time.db";
      String myPath = DB_PATH + dbName;
      SQLiteDatabase theDatabase = SQLiteDatabase.openDatabase(myPath,
          null, SQLiteDatabase.OPEN_READWRITE
              | SQLiteDatabase.NO_LOCALIZED_COLLATORS);

      // theDatabase.query("data", new String[] {KEY_CITY, KEY_TIMEZONE,
      // KEY_COUNTRY, KEY_TIMEZONE_DISPLAY_NAME,
      // KEY_TIMEZONE_ID},_ID+" = '"+id+"';", null, null, null, null,
      // null);

      final String _ID = "_id";
      final String DATABASE_TABLE = "data";
      final String KEY_CITY = "city";
      final String KEY_COUNTRY = "country";
      final String KEY_TIMEZONE = "timezone";
      final String KEY_TIMEZONE_DISPLAY_NAME = "display_name";
      final String KEY_TIMEZONE_ID = "timezone_id";
      String s = "(GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi";
      Cursor c;
      try {
        c = theDatabase.query("data", new String[] { KEY_CITY,
            KEY_TIMEZONE, KEY_COUNTRY, KEY_TIMEZONE_DISPLAY_NAME,
            KEY_TIMEZONE_ID, _ID }, null, null, null, null, null, null);
        
        int count = c.getCount();
        c.moveToFirst();
        for (int i = 0; i < count; i++) {
          System.out.println("city:" + c.getString(0));
          System.out.println("timezone:" + c.getString(1));
          System.out.println("country:" + c.getString(2));
          System.out.println("display_name:" + c.getString(3));
          System.out.println("timezone_id:" + c.getString(4));
          System.out.println("_id:" + c.getString(5));
          
          Test test = new Test();
          ContentValues contentValues = new ContentValues();
          contentValues.put("city", test.getStringValue(c.getString(0)));
          contentValues.put("timezone", test.getStringValue(c.getString(1)));
          contentValues.put("country", test.getStringValue(c.getString(2)));
          contentValues.put("display_name", test.getStringValue(c.getString(3)));
          contentValues.put("timezone_id", test.getStringValue(c.getString(4)));
          theDatabase.update("data", contentValues, "_id=?",new String[]{test.getStringValue(c.getString(5))} );  
          c.moveToNext();
        }
        c.close();
      } catch (Exception e) {
        Log.e(TimelyPiece.WORLD_CLOCK, "Error getting Timezone for "
            + KEY_CITY + " : " + e.getMessage());
      }




上次一贴居然是9年前了。。。

flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2018 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923