2012-03-06 117 views
1

我一直在關注reign design's guide以在android應用程序中使用預先構建的sqlite數據庫。我創建了db helper類,然後嘗試在java tut之後創建一個新的類實例。該程序編譯並運行,但一直停留在列出的最後一步10分鐘。在android中使用sqlite

我的數據庫名爲sampledatabase,apk文件是Access Db.apk,軟件包名稱空間是access.db。謝謝你的幫助。

[2012-03-06 00:39:47 - Access DB] Android Launch! 
[2012-03-06 00:39:47 - Access DB] adb is running normally. 
[2012-03-06 00:39:47 - Access DB] Performing access.db.AccessDBActivity activity launch 
[2012-03-06 00:39:47 - Access DB] Automatic Target Mode: launching new emulator with compatible AVD 'First' 
[2012-03-06 00:39:47 - Access DB] Launching a new emulator with Virtual Device 'First' 
[2012-03-06 00:39:52 - Emulator] emulator: WARNING: Unable to create sensors port: Unknown error 
[2012-03-06 00:39:52 - Access DB] New emulator found: emulator-5554 
[2012-03-06 00:39:52 - Access DB] Waiting for HOME ('android.process.acore') to be launched... 
[2012-03-06 00:40:30 - Access DB] HOME is up on device 'emulator-5554' 
[2012-03-06 00:40:30 - Access DB] Uploading Access DB.apk onto device 'emulator-5554' 
[2012-03-06 00:40:30 - Access DB] Installing Access DB.apk... 
[2012-03-06 00:40:57 - Access DB] Success! 
[2012-03-06 00:40:57 - Access DB] Starting activity access.db.AccessDBActivity on device emulator-5554 
[2012-03-06 00:40:59 - Access DB] ActivityManager: Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=access.db/.AccessDBActivity } 

    public class DataBaseHelper extends SQLiteOpenHelper{ 

    //new instance of class DataBaseHelper 

    public void main() { 
     DataBaseHelper myDbHelper = new DataBaseHelper(myContext); 
     myDbHelper = new DataBaseHelper(null); 

     try { 

      myDbHelper.createDataBase(); 

     } catch (IOException ioe) { 

      throw new Error("Unable to create database"); 

     } 

     try { 

      myDbHelper.openDataBase(); 

     }catch(SQLException sqle){ 

      throw sqle; 

     } 
    } 

    //The Android's default system path of your application database. 
    private static String DB_PATH = "/data/data/access.db/databases/"; 

    private static String DB_NAME = "sampledatabase"; 

    private SQLiteDatabase myDataBase; 

    private final Context myContext; 

    /** 
    * Constructor 
    * Takes and keeps a reference of the passed context in order to access to the application assets and resources. 
    * @param dataBaseHelper 
    */ 
    public DataBaseHelper(Context dataBaseHelper) { 


     super(dataBaseHelper, DB_NAME, null, 1); 
     this.myContext = dataBaseHelper; 
    } 


    /** 
    * Creates a empty database on the system and rewrites it with your own database. 
    * */ 
    public void createDataBase() throws IOException{ 

     boolean dbExist = checkDataBase(); 

     if(dbExist){ 
      //do nothing - database already exist 
     }else{ 


      //By calling this method and empty database will be created into the default system path 
       //of your application so we are gonna be able to overwrite that database with our database. 
      this.getReadableDatabase(); 

      try { 

       copyDataBase(); 

      } catch (IOException e) { 

       throw new Error("Error copying database"); 

      } 
     } 

    } 

    /** 
    * Check if the database already exist to avoid re-copying the file each time you open the application. 
    * @return true if it exists, false if it doesn't 
    */ 
    private boolean checkDataBase(){ 

     SQLiteDatabase checkDB = null; 

     try{ 
      String myPath = DB_PATH + DB_NAME; 
      checkDB = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); 

     }catch(SQLiteException e){ 

      //database does't exist yet. 

     } 

     if(checkDB != null){ 

      checkDB.close(); 

     } 

     return checkDB != null ? true : false; 
    } 

    /** 
    * Copies your database from your local assets-folder to the just created empty database in the 
    * system folder, from where it can be accessed and handled. 
    * This is done by transfering bytestream. 
    * */ 
    private void copyDataBase() throws IOException{ 

     //Open your local db as the input stream 
     InputStream myInput = myContext.getAssets().open(DB_NAME); 

     // Path to the just created empty db 
     String outFileName = DB_PATH + DB_NAME; 

     //Open the empty db as the output stream 
     OutputStream myOutput = new FileOutputStream(outFileName); 

     //transfer bytes from the inputfile to the outputfile 
     byte[] buffer = new byte[1024]; 
     int length; 
     while ((length = myInput.read(buffer))>0){ 
      myOutput.write(buffer, 0, length); 
     } 

     //Close the streams 
     myOutput.flush(); 
     myOutput.close(); 
     myInput.close(); 

    } 

    public void openDataBase() throws SQLException{ 

     //Open the database 
     String myPath = DB_PATH + DB_NAME; 
     myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); 

    } 

    @Override 
    public synchronized void close() { 

      if(myDataBase != null) 
       myDataBase.close(); 

      super.close(); 

    } 

    @Override 
    public void onCreate(SQLiteDatabase db) { 

    } 

    @Override 
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { 

    } 

     } 

的logcat:

03-06 13:58:17.824: I/SystemServer(66): UI Mode Manager Service 
03-06 13:58:17.984: I/SystemServer(66): Backup Service 
03-06 13:58:18.004: V/BackupManagerService(66): No ancestral data 
03-06 13:58:18.054: I/BackupManagerService(66): Found stale backup journal, scheduling 
03-06 13:58:18.054: I/BackupManagerService(66): com.android.inputmethod.latin 
03-06 13:58:18.054: I/BackupManagerService(66): com.android.browser 
03-06 13:58:18.054: I/BackupManagerService(66): com.android.providers.userdictionary 
03-06 13:58:18.064: I/BackupManagerService(66): android 
03-06 13:58:18.064: I/BackupManagerService(66): com.android.providers.settings 
03-06 13:58:18.064: I/BackupManagerService(66): Backup enabled => true 
03-06 13:58:18.074: I/SystemServer(66): AppWidget Service 
03-06 13:58:18.074: I/SystemServer(66): Recognition Service 
03-06 13:58:18.085: I/SystemServer(66): DiskStats Service 
03-06 13:58:18.104: I/WindowManager(66): SAFE MODE not enabled 
03-06 13:58:18.104: D/dalvikvm(66): JIT started for system_server 
03-06 13:58:18.414: D/dalvikvm(66): GC_CONCURRENT freed 281K, 44% free 3823K/6727K, external 1625K/2137K, paused 28ms+39ms 
03-06 13:58:18.434: D/PowerManagerService(66): system ready! 
03-06 13:58:18.434: I/ActivityManager(66): System now ready 
03-06 13:58:18.454: I/SystemServer(66): Making services ready 
03-06 13:58:18.464: I/StatusBarManagerService(66): Starting service: ComponentInfo{com.android.systemui/com.android.systemui.statusbar.StatusBarService} 
03-06 13:58:18.484: I/Zygote(66): Process: zygote socket opened 
03-06 13:58:18.504: I/ActivityManager(66): Start proc com.android.systemui for service com.android.systemui/.statusbar.StatusBarService: pid=115 uid=1000 gids={3002, 3001, 3003} 
03-06 13:58:18.504: I/ActivityManager(66): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=0 keys=0/0/0 nav=0/0 orien=0 layout=0 uiMode=17 seq=2} 
03-06 13:58:18.534: I/ActivityManager(66): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=3} 
03-06 13:58:18.544: W/RecognitionManagerService(66): no available voice recognition services found 
03-06 13:58:18.864: I/ActivityManager(66): Start proc jp.co.omronsoft.openwnn for service jp.co.omronsoft.openwnn/.OpenWnnJAJP: pid=122 uid=10004 gids={} 
03-06 13:58:18.914: D/NetworkManagmentService(66): Registering observer 
03-06 13:58:18.914: E/ThrottleService(66): Could not open GPS configuration file /etc/gps.conf 
03-06 13:58:18.954: I/ActivityManager(66): Start proc com.android.phone for added application com.android.phone: pid=126 uid=1001 gids={3002, 3001, 3003, 1015} 
03-06 13:58:19.014: W/GpsLocationProvider(66): Could not open GPS configuration file /etc/gps.conf 
03-06 13:58:19.045: I/ActivityManager(66): Start proc com.android.systemui for added application com.android.systemui: pid=130 uid=1000 gids={3002, 3001, 3003} 
03-06 13:58:19.214: I/ActivityManager(66): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.HOME] flg=0x10000000 cmp=com.android.launcher/com.android.launcher2.Launcher } from pid 0 
03-06 13:58:19.284: I/ActivityManager(66): Start proc com.android.launcher for activity com.android.launcher/com.android.launcher2.Launcher: pid=134 uid=10013 gids={} 
03-06 13:58:19.284: I/SystemServer(66): Enabled StrictMode for system server main thread. 
03-06 13:58:19.524: E/logwrapper(136): executing /system/bin/tc failed: No such file or directory 
03-06 13:58:19.554: I/logwrapper(29): /system/bin/tc terminated by exit(1) 
03-06 13:58:19.594: E/logwrapper(137): executing /system/bin/tc failed: No such file or directory 
03-06 13:58:19.624: I/logwrapper(29): /system/bin/tc terminated by exit(1) 
03-06 13:58:19.654: E/logwrapper(140): executing /system/bin/tc failed: No such file or directory 
03-06 13:58:19.654: I/logwrapper(29): /system/bin/tc terminated by exit(1) 
03-06 13:58:20.124: D/dalvikvm(66): GC_EXTERNAL_ALLOC freed 152K, 43% free 3892K/6727K, external 2130K/2137K, paused 377ms 
03-06 13:58:20.124: W/ActivityManager(66): Unable to start service Intent { [email protected] }: not found 
03-06 13:58:20.184: W/ActivityManager(66): No pending application record for pid 115 (IApplicationThread [email protected]); dropping process 
03-06 13:58:20.184: I/Process(66): Sending signal. PID: 115 SIG: 9 
03-06 13:58:20.384: W/ActivityManager(66): Unable to start service Intent { [email protected] }: not found 
03-06 13:58:20.704: D/qemud(37): fdhandler_accept_event: accepting on fd 9 
03-06 13:58:20.704: D/qemud(37): created client 0x12f88 listening on fd 12 
03-06 13:58:20.804: D/qemud(37): client_fd_receive: attempting registration for service 'gps' 
03-06 13:58:20.804: D/qemud(37): client_fd_receive: -> received channel id 4 
03-06 13:58:20.814: D/qemud(37): client_registration: registration succeeded for client 4 
03-06 13:58:21.484: D/dalvikvm(66): GC_EXTERNAL_ALLOC freed 40K, 43% free 3892K/6727K, external 2729K/2770K, paused 501ms 
03-06 13:58:21.574: I/ActivityManager(66): Start proc com.android.settings for broadcast com.android.settings/.widget.SettingsAppWidgetProvider: pid=164 uid=1000 gids={3002, 3001, 3003} 
03-06 13:58:21.594: D/dalvikvm(122): GC_CONCURRENT freed 404K, 54% free 2641K/5639K, external 1625K/2137K, paused 29ms+86ms 
03-06 13:58:21.634: D/dalvikvm(126): GC_CONCURRENT freed 405K, 54% free 2640K/5639K, external 1625K/2137K, paused 11ms+77ms 
03-06 13:58:21.874: D/dalvikvm(134): GC_CONCURRENT freed 407K, 54% free 2638K/5639K, external 1625K/2137K, paused 5ms+89ms 
03-06 13:58:21.894: D/dalvikvm(130): GC_CONCURRENT freed 408K, 54% free 2636K/5639K, external 1625K/2137K, paused 7ms+48ms 
03-06 13:58:22.034: I/ActivityThread(134): Pub com.android.launcher2.settings: com.android.launcher2.LauncherProvider 
03-06 13:58:22.324: D/dalvikvm(122): No JNI_OnLoad found in /system/lib/libwnndict.so 0x40513468, skipping init 
03-06 13:58:22.404: I/ActivityThread(126): Pub mms: com.android.providers.telephony.MmsProvider 
03-06 13:58:22.614: I/ActivityThread(126): Pub sms: com.android.providers.telephony.SmsProvider 
03-06 13:58:22.684: I/ActivityThread(126): Pub telephony: com.android.providers.telephony.TelephonyProvider 
03-06 13:58:22.684: I/ActivityThread(126): Pub icc: com.android.phone.IccProvider 
03-06 13:58:22.764: I/ActivityThread(126): Pub mms-sms: com.android.providers.telephony.MmsSmsProvider 
03-06 13:58:22.874: D/dalvikvm(66): GREF has increased to 201 
03-06 13:58:23.014: D/dalvikvm(122): GC_CONCURRENT freed 274K, 50% free 2936K/5831K, external 1625K/2137K, paused 4ms+4ms 
03-06 13:58:23.715: D/dalvikvm(66): GC_EXTERNAL_ALLOC freed 172K, 42% free 3990K/6791K, external 3337K/3347K, paused 301ms 
03-06 13:58:23.804: I/StatusBarManagerService(66): registerStatusBar [email protected]8 
03-06 13:58:24.074: D/VoldCmdListener(28): share status ums 
03-06 13:58:24.084: D/StorageNotification(130): Startup with UMS connection false (media state removed) 
03-06 13:58:24.174: I/StorageNotification(130): UMS connection changed to false (media state removed) 
03-06 13:58:24.234: D/dalvikvm(164): GC_CONCURRENT freed 408K, 54% free 2636K/5639K, external 1625K/2137K, paused 5ms+59ms 
03-06 13:58:24.385: D/CallManager(126): registerPhone(GSM Handler{40560f98}) 
03-06 13:58:24.544: I/ActivityManager(66): Start proc android.process.acore for content provider com.android.providers.contacts/.CallLogProvider: pid=185 uid=10006 gids={3003, 1015} 
03-06 13:58:24.644: D/dalvikvm(122): GC_CONCURRENT freed 421K, 49% free 3186K/6215K, external 1625K/2137K, paused 5ms+20ms 
03-06 13:58:24.934: D/dalvikvm(66): GC_EXTERNAL_ALLOC freed 68K, 42% free 3997K/6791K, external 3201K/3747K, paused 351ms 
03-06 13:58:25.174: W/ActivityManager(66): Unable to start service Intent { act=com.android.ussd.IExtendedNetworkService }: not found 
03-06 13:58:25.274: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 50K, 53% free 2697K/5639K, external 2128K/2137K, paused 458ms 
03-06 13:58:25.464: I/TelephonyRegistry(66): notifyServiceState: 3 home null null null Unknown CSS not supported -1 -1RoamInd: -1DefRoamInd: -1EmergOnly: false 
03-06 13:58:25.714: D/AlarmManagerService(66): Kernel timezone updated to 300 minutes west of GMT 
03-06 13:58:25.914: D/SystemClock(126): Setting time of day to sec=1331060305 
03-06 13:58:25.488: W/SystemClock(126): Unable to set rtc to 1331060305: Invalid argument 
03-06 13:58:25.598: I/ActivityManager(66): Start proc com.android.deskclock for broadcast com.android.deskclock/.AlarmInitReceiver: pid=195 uid=10019 gids={} 
03-06 13:58:25.707: I/TelephonyRegistry(66): notifyDataConnection: state=0 isDataConnectivityPossible=false reason=radioTurnedOff interfaceName=null networkType=0 
03-06 13:58:25.727: I/TelephonyRegistry(66): notifyDataConnection: state=0 isDataConnectivityPossible=false reason=gprsDetached interfaceName=null networkType=0 
03-06 13:58:26.257: D/dalvikvm(66): GC_EXTERNAL_ALLOC freed 162K, 42% free 4052K/6919K, external 4073K/5086K, paused 311ms 
03-06 13:58:26.397: I/ActivityThread(185): Pub com.android.social: com.android.providers.contacts.SocialProvider 
03-06 13:58:26.637: I/ActivityThread(185): Pub applications: com.android.providers.applications.ApplicationsProvider 
03-06 13:58:27.177: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 25K, 52% free 2720K/5639K, external 2668K/2681K, paused 756ms 
03-06 13:58:27.587: D/dalvikvm(185): GC_CONCURRENT freed 407K, 54% free 2613K/5639K, external 1625K/2137K, paused 5ms+64ms 
03-06 13:58:27.868: I/TelephonyRegistry(66): notifyServiceState: 0 home Android Android 310260 UMTS CSS not supported -1 -1RoamInd: -1DefRoamInd: -1EmergOnly: false 
03-06 13:58:27.927: I/TelephonyRegistry(66): notifyDataConnection: state=0 isDataConnectivityPossible=false reason=null interfaceName=null networkType=3 
03-06 13:58:28.827: D/MccTable(126): updateMccMncConfiguration: mcc=310, mnc=260 
03-06 13:58:28.827: D/MccTable(126): locale set to en_us 
03-06 13:58:28.937: I/ActivityThread(185): Pub contacts;com.android.contacts: com.android.providers.contacts.ContactsProvider2 
03-06 13:58:28.947: D/MccTable(126): WIFI_NUM_ALLOWED_CHANNELS set to 11 
03-06 13:58:29.107: I/WifiService(66): WifiService trying to setNumAllowed to 11 with persist set to true 
03-06 13:58:29.117: I/ActivityManager(66): Config changed: { scale=1.0 imsi=310/260 loc=en_US touch=3 keys=2/1/2 nav=3/1 orien=1 layout=34 uiMode=17 seq=4} 
03-06 13:58:29.207: D/dalvikvm(126): GC_CONCURRENT freed 227K, 50% free 2927K/5767K, external 1625K/2137K, paused 8ms+108ms 
03-06 13:58:29.327: I/TelephonyRegistry(66): notifyMessageWaitingChanged: false 
03-06 13:58:29.327: I/TelephonyRegistry(66): notifyCallForwardingChanged: false 
03-06 13:58:29.527: I/ActivityThread(195): Pub com.android.deskclock: com.android.deskclock.AlarmProvider 
03-06 13:58:29.807: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 6K, 52% free 2732K/5639K, external 3368K/3387K, paused 889ms 
03-06 13:58:29.888: D/dalvikvm(195): GC_CONCURRENT freed 370K, 54% free 2616K/5639K, external 1625K/2137K, paused 11ms+71ms 
03-06 13:58:30.207: W/ActivityManager(66): Activity idle timeout for HistoryRecord{405e49b8 com.android.launcher/com.android.launcher2.Launcher} 
03-06 13:58:30.297: D/PowerManagerService(66): bootCompleted 
03-06 13:58:30.497: D/AndroidRuntime(199): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
03-06 13:58:30.547: D/AndroidRuntime(199): CheckJNI is ON 
03-06 13:58:30.647: D/dalvikvm(66): GC_CONCURRENT freed 442K, 43% free 4090K/7175K, external 4373K/5573K, paused 6ms+14ms 
03-06 13:58:30.787: I/ActivityManager(66): Start proc com.android.protips for broadcast com.android.protips/.ProtipWidget: pid=217 uid=10024 gids={} 
03-06 13:58:31.057: D/dalvikvm(32): GC_EXPLICIT freed 10K, 53% free 2538K/5379K, external 1625K/2137K, paused 284ms 
03-06 13:58:31.257: D/TelephonyProvider(126): Setting numeric '310260' to be the current operator 
03-06 13:58:31.367: I/TelephonyRegistry(66): notifyDataConnection: state=1 isDataConnectivityPossible=true reason=simLoaded interfaceName=null networkType=3 
03-06 13:58:31.487: I/TelephonyRegistry(66): notifyDataConnection: state=2 isDataConnectivityPossible=true reason=simLoaded interfaceName=/dev/omap_csmi_tty1 networkType=3 
03-06 13:58:31.617: D/dalvikvm(32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 488ms 
03-06 13:58:31.718: D/Tethering(66): MasterInitialState.processMessage what=3 
03-06 13:58:31.947: D/SntpClient(66): request time failed: java.net.SocketException: Address family not supported by protocol 
03-06 13:58:32.027: D/dalvikvm(32): GC_EXPLICIT freed <1K, 53% free 2538K/5379K, external 1625K/2137K, paused 283ms 
03-06 13:58:32.517: I/ActivityThread(185): Pub call_log: com.android.providers.contacts.CallLogProvider 
03-06 13:58:32.577: I/ActivityThread(185): Pub user_dictionary: com.android.providers.userdictionary.UserDictionaryProvider 
03-06 13:58:32.727: I/ActivityManager(66): Start proc com.android.music for broadcast com.android.music/.MediaAppWidgetProvider: pid=232 uid=10005 gids={3003, 1015} 
03-06 13:58:32.827: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 54K, 51% free 2779K/5639K, external 4217K/4261K, paused 228ms 
03-06 13:58:33.118: I/SearchManagerService(66): Building list of searchable activities 
03-06 13:58:33.857: I/ActivityManager(66): Start proc com.android.quicksearchbox for broadcast com.android.quicksearchbox/.SearchWidgetProvider: pid=241 uid=10002 gids={3003} 
03-06 13:58:33.927: D/AndroidRuntime(199): Calling main entry com.android.commands.pm.Pm 
03-06 13:58:33.927: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 28K, 51% free 2800K/5639K, external 5345K/5346K, paused 266ms 
03-06 13:58:34.167: W/WindowManager(66): App freeze timeout expired. 
03-06 13:58:34.167: W/WindowManager(66): Force clearing freeze: AppWindowToken{40609a78 token=HistoryRecord{405e49b8 com.android.launcher/com.android.launcher2.Launcher}} 
03-06 13:58:34.247: I/ActivityManager(66): Start proc com.android.defcontainer for service com.android.defcontainer/.DefaultContainerService: pid=251 uid=10003 gids={1015, 2001} 
03-06 13:58:34.257: D/dalvikvm(66): GREF has increased to 301 
03-06 13:58:34.448: D/dalvikvm(134): GC_EXPLICIT freed 20K, 51% free 2806K/5639K, external 5417K/6692K, paused 298ms 
03-06 13:58:35.017: I/ActivityThread(241): Pub com.android.quicksearchbox.google: com.android.quicksearchbox.google.GoogleSuggestionProvider 
03-06 13:58:35.107: I/ActivityThread(241): Pub com.android.quicksearchbox.shortcuts: com.android.quicksearchbox.ShortcutsProvider 
03-06 13:58:35.257: D/OtaStartupReceiver(126): Not a CDMA phone, no need to process OTA 
03-06 13:58:35.298: I/ActivityManager(66): Start proc android.process.media for broadcast com.android.providers.downloads/.DownloadReceiver: pid=261 uid=10000 gids={1015, 1006, 2001, 3003} 
03-06 13:58:35.317: I/RecoverySystem(66): No recovery log file 
03-06 13:58:36.367: D/dalvikvm(66): GC_EXPLICIT freed 500K, 44% free 4107K/7303K, external 4373K/5573K, paused 181ms 
03-06 13:58:36.437: I/ActivityThread(261): Pub media: com.android.providers.media.MediaProvider 
03-06 13:58:36.607: V/MediaProvider(261): Attached volume: internal 
03-06 13:58:36.667: I/ActivityThread(261): Pub downloads: com.android.providers.downloads.DownloadProvider 
03-06 13:58:36.787: I/ActivityThread(261): Pub drm: com.android.providers.drm.DrmProvider 
03-06 13:58:37.017: I/ActivityManager(66): Start proc com.android.mms for broadcast com.android.mms/.transaction.MmsSystemEventReceiver: pid=272 uid=10015 gids={3003, 1015} 
03-06 13:58:38.207: I/SurfaceFlinger(66): Boot is finished (26914 ms) 
03-06 13:58:38.288: I/ARMAssembler(66): generated scanline__00000177:03010104_00000002_00000000 [ 44 ipp] (66 ins) at [0x44620290:0x44620398] in 899732 ns 
03-06 13:58:38.288: I/ARMAssembler(66): generated scanline__00000177:03515104_00000001_00000000 [ 73 ipp] (95 ins) at [0x446203a0:0x4462051c] in 811985 ns 
03-06 13:58:38.478: I/ActivityThread(272): Pub com.android.mms.SuggestionsProvider: com.android.mms.SuggestionsProvider 
03-06 13:58:39.257: I/ActivityManager(66): Start proc com.android.email for broadcast com.android.email/.service.EmailBroadcastReceiver: pid=292 uid=10028 gids={3003, 1015} 
03-06 13:58:39.917: I/ActivityThread(292): Pub com.android.email.provider: com.android.email.provider.EmailProvider 
03-06 13:58:39.957: I/ActivityThread(292): Pub com.android.email.attachmentprovider: com.android.email.provider.AttachmentProvider 
03-06 13:58:39.957: I/ActivityThread(292): Pub com.android.exchange.provider: com.android.exchange.provider.ExchangeProvider 
03-06 13:58:40.107: D/EAS SyncManager(292): !!! EAS SyncManager, onCreate 
03-06 13:58:40.867: D/Eas Debug(292): Logging: 
03-06 13:58:40.927: D/EAS SyncManager(292): !!! EAS SyncManager, onDestroy 
03-06 13:58:41.007: D/MediaScannerService(261): start scanning volume internal 
03-06 13:58:41.197: D/Email(292): BOOT_COMPLETED 
03-06 13:58:41.297: D/EAS SyncManager(292): !!! EAS SyncManager, onCreate 
03-06 13:58:41.329: D/EAS SyncManager(292): !!! EAS SyncManager, onStartCommand 
03-06 13:58:41.508: D/dalvikvm(251): GC_EXPLICIT freed 315K, 54% free 2543K/5511K, external 1625K/2137K, paused 236ms 
03-06 13:58:41.659: D/EAS SyncManager(292): !!! EAS SyncManager, stopping self 
03-06 13:58:41.667: D/EAS SyncManager(292): !!! EAS SyncManager, onDestroy 
03-06 13:58:41.897: W/ActivityManager(66): No content provider found for: 
03-06 13:58:41.967: D/dalvikvm(126): GREF has increased to 201 
03-06 13:58:42.017: W/ActivityManager(66): No content provider found for: 
03-06 13:58:42.047: D/PackageParser(66): Scanning package: /data/app/vmdl-1212845771.tmp 
03-06 13:58:42.517: D/MediaScanner(261): prescan time: 701ms 
03-06 13:58:42.517: D/MediaScanner(261):  scan time: 69ms 
03-06 13:58:42.517: D/MediaScanner(261): postscan time: 0ms 
03-06 13:58:42.517: D/MediaScanner(261): total time: 770ms 
03-06 13:58:42.679: I/PackageManager(66): Removing non-system package:access.db 
03-06 13:58:43.007: D/PackageManager(66): Scanning package access.db 
03-06 13:58:43.007: I/PackageManager(66): Package access.db codePath changed from /data/app/access.db-2.apk to /data/app/access.db-1.apk; Retaining data and using new 
03-06 13:58:43.019: I/PackageManager(66): Unpacking native libraries for /data/app/access.db-1.apk 
03-06 13:58:43.037: D/installd(34): DexInv: --- BEGIN '/data/app/access.db-1.apk' --- 
03-06 13:58:43.217: D/dalvikvm(311): DexOpt: load 30ms, verify+opt 32ms 
03-06 13:58:43.227: D/installd(34): DexInv: --- END '/data/app/access.db-1.apk' (success) --- 
**03-06 13:58:43.237: W/PackageManager(66): Code path for pkg : access.db changing from /data/app/access.db-2.apk to /data/app/access.db-1.apk 
03-06 13:58:43.237: W/PackageManager(66): Resource path for pkg : access.db changing from /data/app/access.db-2.apk to /data/app/access.db-1.apk** 
03-06 13:58:43.237: D/PackageManager(66): Activities: access.db.AccessDBActivity 
03-06 13:58:43.397: D/dalvikvm(134): GC_EXTERNAL_ALLOC freed 258K, 49% free 3011K/5895K, external 6685K/6692K, paused 76ms 
03-06 13:58:43.557: I/installd(34): move /data/dalvik-cache/[email protected]@[email protected] -> /data/dalvik-cache/[email protected]@[email protected] 
03-06 13:58:43.557: D/PackageManager(66): New package installed in /data/app/access.db-1.apk 
03-06 13:58:43.727: D/dalvikvm(134): GC_EXPLICIT freed 104K, 51% free 2925K/5895K, external 4753K/5582K, paused 61ms 
03-06 13:58:44.428: I/ActivityManager(66): Force stopping package access.db uid=10035 
03-06 13:58:44.438: I/ActivityManager(66): Force stopping package access.db uid=10035 
03-06 13:58:44.547: D/MediaScannerService(261): done scanning volume internal 
03-06 13:58:44.597: I/ActivityManager(66): Force stopping package access.db uid=10035 
03-06 13:58:44.757: I/ActivityManager(66): Start proc com.svox.pico for broadcast com.svox.pico/.VoiceDataInstallerReceiver: pid=313 uid=10009 gids={} 
03-06 13:58:44.807: W/RecognitionManagerService(66): no available voice recognition services found 
03-06 13:58:45.127: I/ActivityThread(313): Pub com.svox.pico.providers.SettingsProvider: com.svox.pico.providers.SettingsProvider 
03-06 13:58:45.247: D/dalvikvm(185): GC_EXPLICIT freed 279K, 52% free 2768K/5703K, external 1625K/2137K, paused 616ms 
03-06 13:58:45.408: D/dalvikvm(66): GC_EXPLICIT freed 1236K, 48% free 4238K/8135K, external 4373K/5573K, paused 103ms 
03-06 13:58:45.467: I/installd(34): unlink /data/dalvik-cache/[email protected]@[email protected] 
03-06 13:58:45.477: D/AndroidRuntime(199): Shutting down VM 
03-06 13:58:45.502: I/AndroidRuntime(199): NOTE: attach of thread 'Binder Thread #3' failed 
03-06 13:58:45.502: D/dalvikvm(199): GC_CONCURRENT freed 100K, 72% free 293K/1024K, external 0K/0K, paused 1ms+1ms 
03-06 13:58:45.508: D/jdwp(199): adbd disconnected 
03-06 13:58:46.218: D/AndroidRuntime(326): >>>>>> AndroidRuntime START com.android.internal.os.RuntimeInit <<<<<< 
03-06 13:58:46.218: D/AndroidRuntime(326): CheckJNI is ON 
03-06 13:58:46.997: D/AndroidRuntime(326): Calling main entry com.android.commands.am.Am 
03-06 13:58:47.038: I/ActivityManager(66): Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=access.db/.AccessDBActivity } from pid 326 
03-06 13:58:47.089: I/ActivityManager(66): Start proc access.db for activity access.db/.AccessDBActivity: pid=334 uid=10035 gids={} 
03-06 13:58:47.128: D/AndroidRuntime(326): Shutting down VM 
03-06 13:58:47.137: D/dalvikvm(326): GC_CONCURRENT freed 100K, 69% free 318K/1024K, external 0K/0K, paused 1ms+1ms 
03-06 13:58:47.148: D/jdwp(326): adbd disconnected 
03-06 13:58:47.187: I/AndroidRuntime(326): NOTE: attach of thread 'Binder Thread #3' failed 
03-06 13:58:48.258: I/ActivityManager(66): Displayed access.db/.AccessDBActivity: +1s180ms (total +29s481ms) 
03-06 13:58:48.258: I/ActivityManager(66): Displayed com.android.launcher/com.android.launcher2.Launcher: +29s486ms 
03-06 14:01:05.130: I/dalvikvm(66): Jit: resizing JitTable from 512 to 1024 
03-06 14:03:32.877: D/SntpClient(66): request time failed: java.net.SocketException: Address family not supported by protocol 
+0

你能簡單地解釋一下它卡在哪一步嗎? – Naved 2012-03-06 06:20:50

+0

關於此步驟:[2012-03-06 00:40:59 - 訪問數據庫] ActivityManager:啓動:Intent {act = android.intent.action.MAIN cat = [android.intent.category.LAUNCHER] cmp = access。 db/.AccessDBActivity} – mdegges 2012-03-06 06:33:16

+1

http://stackoverflow.com/a/9109728/265167 – 2012-03-06 06:43:46

回答

2

您正在使用SQLiteOpenHelper錯誤。當某些東西試圖訪問數據庫並且找不到時,會調用onCreate方法。在這裏實現您的數據庫表創建(或更好地調用所做的方法)。您的數據庫將被創建並完成初始請求。您可以在onUpdate方法中編寫數據庫更新的邏輯。如果給定的版本高於數據庫當前的版本(在SQLiteOpenHelper構造函數中),則Android調用onUpate()。

請謹慎地將SQLiteOpenHelper擴展爲實用程序類。每次創建此類的實例時,您還創建一個SQLiteOpenHelper對象及其繼承的所有對象。如果你不需要,不要添加到堆中