管理大量数据时出现意外的应用程序崩溃

时间:2015-10-15 18:12:34

标签: java android sqlite android-sqlite

我有一个服务,它将自动同步大约7,000个数据库记录(从MySQL到SQLite通过一些asmx webservices)和大约100 MB的文件。现在我只有各种测试数据,Aprox 400,000条记录和500 MB数据。

我使用以下代码在MainActivity上启动服务: SyncFromWeb = new Intent(context, SyncFromWeb.class); startService(SyncFromWeb);

我的服务每分钟检查一次数据库,看看是否需要同步并下载数据。除此之外,我有两个Intent Services正在运行以从平板电脑同步到中央数据库。一个只调用webservices(调用存储在SQLite表中),另一个调用在应用程序中获取的图像。如果用户拍摄太多照片,我会使用这种方法来减慢数据更新速度。

我的服务看起来像这样(部分):

public class SyncFromWeb extends Service {

private static final String TAG = "Sync Data From Web";
private boolean isRunning = false;
private List<Pair<String, Object>> ParameterList = new ArrayList<Pair<String, Object>>();

private final String WebServiceURL = Constants.URL_BASE + "Android_DAL.asmx";
private final String NameSpace = "http://tempuri.org/";

private Handler Mainhandler;
@Override
public void onCreate() {
    isRunning = true;
    Mainhandler = new Handler();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    final Context context = this;
    Log.d(TAG, "Starting Sync From Web Service");

    new Thread(new Runnable() {
        @Override
        public void run() {
            // boolean Variables declaration

            DatabaseHandler db = new DatabaseHandler(context);

            SimpleDateFormat DateTimeFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
            String ExecutionDateTime = "";
            Date CurrentDateTime = new Date();
            Date NextExecutionDateTime = new Date();

            while(ExecutionDateTime.trim().equals("")) {
                ExecutionDateTime  = GetTaskExecutionTime(GetManufacturerSerialNumber());

                if(ExecutionDateTime.trim().equals("")) {
                    try {
                        Thread.sleep(5000);
                    }
                    catch (Exception ex) { Log.d(TAG, "Exception while getting Execution Task Time. Details: " + ex.getMessage()); }
                }
            }

    // Not all the tablets are going to synchronize
            isRunning = !ExecutionDateTime.equals("NO SYNC");

            while(isRunning) {
                try {
                    CurrentDateTime = new Date();
                    NextExecutionDateTime = DateTimeFormatter.parse(ExecutionDateTime);
                }
                catch(Exception ex) {
                    Log.d(TAG, "");
                }

                if(CurrentDateTime.compareTo(NextExecutionDateTime) > 0) {
                    ShowToast("Running scheduled syncronization from Web Database...");

                    //... Download data routines

                    if(WorkListDataDone && WorkListStageDataDone && WorkListInspectionPointDataDone && WorkListInspectionResultDataDone && WorkListInspectionResultPictureDataDone && InspectionKitDataDone && ListsDataDone) {
                        //.. Booleans set to false 
                        SetNextSynchronizationTime(GetManufacturerSerialNumber());

//.. Calculate local next sync time, current sync time plus 24 hours
                        ShowToast("Today's synchronization finished...");
                    }
                    db.close();
                }
                else {

                    try {
            // If it's not time to execute, check back in one minute
                        Thread.sleep(1000*60);
                    }
                    catch (Exception ex) { Log.d(TAG, "Exception on Thread.Sleep."); }
                }
            }
        }
    }).start();

    return Service.START_NOT_STICKY;
}

@Override
public IBinder onBind(Intent arg0) {
    return null;
}

@Override
public void onDestroy() {
    isRunning = false;

    Log.d(TAG, "Service Destroyed");
}

private String GetTaskExecutionTime(String TabletSerialNumber) {
    String MethodName = "SyncToTablet_Tablet_Get";
    String ExecutionDateTime = "NO SYNC";

    //.. Retrieve sync date time from Db

    return ExecutionDateTime;
}

private void SetNextSynchronizationTime(String TabletSerialNumber) {
    String MethodName = "SyncToTablet_Tablet_Update_Sync_Time";
    //.. Update next sync date time to db
}

private boolean UpdateListData(DatabaseHandler SQLLiteHandler) {
    try {
        ShowToast("Updating List data from Web Database...");

        //.... Normal processing, no problems
    }
    catch(Exception ex) {
        ShowToast("An error ocurred while synchronizing Lists data from Web Database. Retrying...");
        Log.d(TAG, "An Exception occurred on CreateListData. Details: " + ex.getMessage());
        return false;
    }

    return true;
}

private Pair<List<com.MyCompany.systm.qirs.obj.List>, List<com.MyCompany.systm.qirs.obj.List>> GetListsList() throws Exception {
    List<com.MyCompany.systm.qirs.obj.List> ReturnToDeleteList = new ArrayList<com.MyCompany.systm.qirs.obj.List>();
    List<com.MyCompany.systm.qirs.obj.List> ReturnToInsertList = new ArrayList<com.MyCompany.systm.qirs.obj.List>();


//... Normal processing, no problems

    return new Pair<List<com.MyCompany.systm.qirs.obj.List>, List<com.MyCompany.systm.qirs.obj.List>>(ReturnToDeleteList, ReturnToInsertList);
}

// Function to retrieve the various chunks of data from the webservice
private Pair<Boolean, JSONArray> GetWorklistData(String MethodName, String FromDateTime, String TableName, int StartingIndex, int RowQuantity) {
    JSONArray returnJSONArray = null;
    Boolean succesfullExecution = false;

    ParameterList.clear();
    ParameterList.add(new Pair<String, Object>("FromDateTime", FromDateTime));
    ParameterList.add(new Pair<String, Object>("LimitFrom", StartingIndex));
    ParameterList.add(new Pair<String, Object>("Offset", RowQuantity));

    SoapSerializationEnvelope SOAPEnvelope;

    SOAPEnvelope = CreateSOAPConnection("http://tempuri.org/", WebServiceURL, MethodName, ParameterList);

    try {
        SoapPrimitive SOAPJson = (SoapPrimitive) SOAPEnvelope.getResponse();
        JSONObject jsonRootObject = new JSONObject(SOAPJson.toString());
        returnJSONArray = jsonRootObject.optJSONArray(TableName);
        succesfullExecution = true;
    } catch (Exception ex) {
        ShowToast("An error ocurred while retrieving the Worklist data from Web Database. Retrying...");
        Log.d(TAG, "An Exception occurred on GetWorklistData. Details: " + ex.getMessage());
    }

    return new Pair<Boolean, JSONArray>(succesfullExecution, returnJSONArray);
}

private boolean UpdateWorkListData(DatabaseHandler db, String FromDateTime) {
    String MethodName = "SyncToTablet_WorklistData";
    String TableName = "worklist";
    int StartingIndex = 0;
    int RowQuantity = 1000;
    boolean Succesfull = false;

    SQLiteDatabase SQLLiteDb = db.GetSQLiteInstance();

    while(true) {
        Pair<Boolean, JSONArray> WorklistDataFromWeb = GetWorklistData(MethodName, FromDateTime, TableName, StartingIndex, RowQuantity);

        if(WorklistDataFromWeb.first && (WorklistDataFromWeb.second == null || WorklistDataFromWeb.second.length() == 0)) {
            Succesfull = true;
            break;
        }

        JSONArray jsonArrayWorklist =  WorklistDataFromWeb.second;

        try {
            ShowToast("Updating Worklist data from Web Database...");

            for(int i=0; i < jsonArrayWorklist.length(); i++) {
                JSONObject jsonObject = jsonArrayWorklist.getJSONObject(i);

                db.DeleteALLWorkList(SQLLiteDb, jsonObject.getString("ID"));
                db.AddWorkList(SQLLiteDb, new WorkList(jsonObject.getString("ID"),
                                jsonObject.getString("TabletSerial"),
                                jsonObject.getString("SAP_No"),
                                jsonObject.getString("Serial"),
                                jsonObject.getString("Unit"),
                                jsonObject.getString("Model"),
                                jsonObject.getString("Number"),
                                jsonObject.getString("Customer_Name"),
                                jsonObject.getInt("Line_ID"),
                                jsonObject.getInt("List_ID"))
                );
            }

            StartingIndex += RowQuantity;
        }
        catch (Exception ex) {
            ShowToast("An error ocurred while Synchronizing the Worklist data from Web Database. Retrying...");
            Log.d(TAG, "An Exception occurred on UpdateWorkListData. Details: " + ex.getMessage());
            break;
        }
    }

    SQLLiteDb.close();

    return Succesfull;
}

private boolean UpdateWorkListStageData(DatabaseHandler db, String FromDateTime) {
    String MethodName = "SyncToTablet_WorklistStageData";
    String TableName = "worklist_stage";
    int StartingIndex = 0;
    int RowQuantity = 1000;
    boolean Succesfull = false;

// Same logic as above method

    return Succesfull;
}

private boolean UpdateWorkListInspectionPointData(DatabaseHandler db, String FromDateTime) {
    String MethodName = "SyncToTablet_WorklistInspectionPointData";
    String TableName = "worklist_inspectionpoint";
    int StartingIndex = 0;
    int RowQuantity = 500;
    boolean Succesfull = false;

// Samle logic as above method. This method has a smaller chunk because there are many columns and it's the biggest table

    return Succesfull;
}

private boolean UpdateWorkListInspectionResultData(DatabaseHandler db, String FromDateTime) {
    String MethodName = "SyncToTablet_WorklistInspectionResultData";
    String TableName = "worklist_inspectionresult";
    int StartingIndex = 0;
    int RowQuantity = 500;
    boolean Succesfull = false;

// Same logic as above method.

    return Succesfull;
}

private boolean UpdateWorkListInspectionResultPictureData(DatabaseHandler db, String FromDateTime) {
    String MethodName = "SyncToTablet_WorklistInspectionResultPicturesData";
    String TableName = "worklist_inspectionresultpictures";
    int StartingIndex = 0;
    int RowQuantity = 5;
    boolean Succesfull = false;

// Same logic as above method. This is a smaller chunk because the images are stored in the database, average size is of 70Kb 

    return true;
}

private boolean UpdateInspectionKitData(DatabaseHandler db, String FromDateTime) {
//.. Do a bunch of stuff, nested loops, each item of second loop creates a file            
CreateInspectionKitFile(jsonObject.getString("Kit_Document").toLowerCase(), jsonObject.getString("Kit_FileName").toLowerCase(), jsonObject.getString("Kit_SAP_No").toLowerCase());

        //.. Rest of code
    return  true;
}

private void CreateInspectionKitFile(String FileName, String ServerFileName, String SubFolder) {
    File SDCardPath = Environment.getExternalStorageDirectory();
    File InspectionKitFileFolder = new File(SDCardPath + "/QIRS/" + SubFolder + "/");
    File InspectionKitFile = new File(SDCardPath + "/QIRS/" + SubFolder + "/" + FileName);

    if(!InspectionKitFile.exists()) {
        ParameterList.clear();
        ParameterList.add(new Pair<String, Object>("FileName", ServerFileName));

        SoapSerializationEnvelope SOAPEnvelope;
        SOAPEnvelope = CreateSOAPConnection("http://tempuri.org/", WebServiceURL, "InspectionKit_GetFile", ParameterList);

        try {
            SoapPrimitive SOAPJson = (SoapPrimitive) SOAPEnvelope.getResponse();

            byte[] FileData = Base64.decode(SOAPJson.toString(), Base64.DEFAULT);

            try {
                InspectionKitFileFolder.mkdirs();

                FileOutputStream fos = new FileOutputStream(InspectionKitFile);
                BufferedOutputStream outputStream = new BufferedOutputStream(fos);
                outputStream.write(FileData);
                outputStream.close();
                fos.close();

                    try {
                        Log.d(TAG, "Finalizing File Data for " + ServerFileName + ".");
                        FileData = null;
                    }
                    catch (Throwable tex) {
                        Log.d(TAG, "Exception while Finalizing File Data Array. Details: "  + tex.getMessage());
                    }
            } catch (IOException ex) {
                Log.d(TAG, "An Exception ocurred on CreateLocalInspectionKitDetail while Creating the File " + FileName + ". Details: " + ex.getMessage());
            }
        } catch (Exception e) {
            Log.d(TAG, "An Exception ocurred on CreateInspectionKitDetail. Details: " + e.getMessage());
        }
    }
}

// Retrieve the tablet serial number
private String GetManufacturerSerialNumber() {
    String SerialNumber = null;
    //.. GEt serial number routine
    return SerialNumber;
}

private SoapSerializationEnvelope CreateSOAPConnection(String NameSpace, String WebServiceURL, String MethodName, List<Pair<String, Object>> Parameters) {
//.. SOAP call to webservice
}

private void ListSubstraction(List<?> ItemsToDeleteList, List<?> FromList) {
    Collection ResultCollection = FromList;
    ResultCollection.removeAll(ItemsToDeleteList);
}

public void ShowToast(final String Message) {
// I was receiving an error about a Looper, this is the only case that I found a reference to Looper, that's why I removed it
//        Handler h = new Handler(SyncFromWeb.this.getMainLooper());

    Mainhandler.post(new Runnable() {
        @Override
        public void run() {
            Toast.makeText(getApplicationContext(), Message, Toast.LENGTH_SHORT).show();
        }
    });
}

该服务运行没有问题,我从2015-09-01开始同步(我的第一天没有太多数据或没有数据)当我到2015-10-02时我的应用程序崩溃了(到这个日期,有很多数据)因为我让它一直运行整夜,它崩溃了,我无法检索任何错误(logcat继续滚动,我不知道我是否可以从日志中检索旧消息),所以我今天再次运行它,执行后大约1小时我收到了这些错误消息:

10-15 09:58:26.320  12045-15369/com.MyCompany.systm.qirs D/Sync Data To Web﹕ Synchronizing data to web database.
10-15 09:58:26.328  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.328  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.335  12045-15370/com.MyCompany.systm.qirs D/Sync Images To Web﹕ Synchronizing images to web database.
10-15 09:58:26.335  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (10) Failed to open database file with errno : 24!
10-15 09:58:26.335  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 32474 of [00bb9c9ce4]
10-15 09:58:26.335  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:32474: (24) open(/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase) -
10-15 09:58:26.335  12045-15370/com.MyCompany.systm.qirs E/SQLiteLog﹕ (10) Failed to open database file with errno : 24!
10-15 09:58:26.335  12045-15370/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 32474 of [00bb9c9ce4]
10-15 09:58:26.335  12045-15370/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:32474: (24) open(/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase) -
10-15 09:58:26.382  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.382  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.414  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.414  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.445  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.445  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.453  12045-15369/com.MyCompany.systm.qirs E/SQLiteDatabase﹕ Failed to open database '/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase'.
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
            at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:238)
            at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
            at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:875)
            at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:843)
            at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
            at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1213)
            at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:236)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
            at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188)
            at com.androidhive.androidsqlite.DatabaseHandler.SyncToWebGetItems(DatabaseHandler.java:2693)
            at com.MyCompany.systm.qirs.SyncToWeb.onHandleIntent(SyncToWeb.java:57)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.os.HandlerThread.run(HandlerThread.java:60)
10-15 09:58:26.460  12045-15370/com.MyCompany.systm.qirs E/SQLiteDatabase﹕ Failed to open database '/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase'.
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
            at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:238)
            at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
            at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:875)
            at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:843)
            at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
            at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1213)
            at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:236)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
            at com.androidhive.androidsqlite.DatabaseHandler.getAllWorkList_InspectionResultPicture(DatabaseHandler.java:2512)
            at com.MyCompany.systm.qirs.SyncImages.onHandleIntent(SyncImages.java:59)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.os.HandlerThread.run(HandlerThread.java:60)
10-15 09:58:26.460  12045-15370/com.MyCompany.systm.qirs W/dalvikvm﹕ threadid=19: thread exiting with uncaught exception (group=0x41589930)
10-15 09:58:26.484  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.484  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.531  12045-15370/com.MyCompany.systm.qirs E/AndroidRuntime﹕ FATAL EXCEPTION: IntentService[SyncImages]
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
            at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:238)
            at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
            at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:875)
            at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:843)
            at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
            at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1213)
            at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:236)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
            at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:164)
            at com.androidhive.androidsqlite.DatabaseHandler.getAllWorkList_InspectionResultPicture(DatabaseHandler.java:2512)
            at com.MyCompany.systm.qirs.SyncImages.onHandleIntent(SyncImages.java:59)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.os.HandlerThread.run(HandlerThread.java:60)
10-15 09:58:26.539  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 30605 of [00bb9c9ce4]
10-15 09:58:26.539  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:30605: (24) open(/data/data/com.MyCompany.systm.qirs/databases) -
10-15 09:58:26.539  12045-15369/com.MyCompany.systm.qirs E/SQLiteOpenHelper﹕ Couldn't open QIRS_DataBase for writing (will try read-only):
    android.database.sqlite.SQLiteCantOpenDatabaseException: unknown error (code 14): Could not open database
            at android.database.sqlite.SQLiteConnection.nativeOpen(Native Method)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:341)
            at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:238)
            at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:515)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:207)
            at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:178)
            at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:875)
            at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:843)
            at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:696)
            at android.app.ContextImpl.openOrCreateDatabase(ContextImpl.java:1213)
            at android.content.ContextWrapper.openOrCreateDatabase(ContextWrapper.java:236)
            at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:224)
            at android.database.sqlite.SQLiteOpenHelper.getReadableDatabase(SQLiteOpenHelper.java:188)
            at com.androidhive.androidsqlite.DatabaseHandler.SyncToWebGetItems(DatabaseHandler.java:2693)
            at com.MyCompany.systm.qirs.SyncToWeb.onHandleIntent(SyncToWeb.java:57)
            at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:176)
            at android.os.HandlerThread.run(HandlerThread.java:60)
10-15 09:58:26.562  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 32474 of [00bb9c9ce4]
10-15 09:58:26.562  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:32474: (24) open(/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase-journal) -
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 32474 of [00bb9c9ce4]
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:32474: (24) open(/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase-journal) -
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (10) Failed to open database file with errno : 24!
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) cannot open file at line 32474 of [00bb9c9ce4]
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) os_unix.c:32474: (24) open(/data/data/com.MyCompany.systm.qirs/databases/QIRS_DataBase-journal) -
10-15 09:58:26.578  12045-12095/com.MyCompany.systm.qirs E/SQLiteLog﹕ (14) statement aborts at 38: [INSERT INTO worklist_inspectionpoint(ID,User_ID,Date_Time,Comments,Pass,List_ID,WorklistStage_ID) VALUES (?,?,?,?,?,?,?)] unable to open database file
10-15 09:58:26.578  12045-15369/com.MyCompany.systm.qirs E/SQLiteLog﹕ (3850) statement aborts at 0: [PRAGMA user_version;] disk I/O error
10-15 09:58:26.585  12045-15369/com.MyCompany.systm.qirs W/dalvikvm﹕ threadid=18: thread exiting with uncaught exception (group=0x41589930)
10-15 09:58:26.585  12045-15369/com.MyCompany.systm.qirs I/Process﹕ Sending signal. PID: 12045 SIG: 9

我知道我在磁盘上有空间,在5.10 Gb中有3.55。我看到一个I / O错误,但我再次运行该程序,它运行没有问题。 最后,当电源连接到平板电脑时,需要执行这项服务(或者我需要稍后更改它),因为此时WiFi访问将可用,我将需要同步到主数据库并下载待处理数据。我现在有广播接收器,可以检测电源何时插上,并显示进度对话框,但它什么也没做。

所以,所有这一切......

1)对可能发生的事情的任何消息? (关于我的错误消息)

2)有关更好地接近我的解决方案的任何建议吗?

3)当您来到蒂华纳时,奖励积分和啤酒(或玉米饼),如何在连接电源时启动服务并使用正在执行的内容更新进度对话框

非常感谢您的帮助

2 个答案:

答案 0 :(得分:0)

错误24是MFILE:“太多打开的文件”。

有些代码会忘记关闭某些文件。

答案 1 :(得分:0)

我删除并再次执行我的代码,逻辑或多或少相同,我使用Services每2分钟将数据同步到数据库。我找到了一种方法来检测平板电脑何时与BroadCastReceiver连接(使用USB或电源)。如果你想知道如何,让我知道分享代码