jeudi 15 octobre 2015

Unexpected app crash when managing large ammounts of data

I have a Service that is going to synchronize around 7,000 database records (from MySQL to SQLite via some asmx webservices) and around 100 MB in files every day automatically. Right now I have only test data of various days, Aprox 400,000 records and 500 MB of data.

I start my service on my MainActivity with the following code: SyncFromWeb = new Intent(context, SyncFromWeb.class); startService(SyncFromWeb);

My Service checks the database every minute to see if it's time to synchronize and does the download of the data. Besides that I have two Intent Services running to synchronize from the tablet to the central database. One only calls webservices (the calls are stored on a SQLite table) and the other synchronizes images that are taken within the application. I use this approach to not slow down the data update if the user takes too many pictures.

My service looks like this (part of):

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();
        }
    });
}

The service runs without a problem, I start my sync from 2015-09-01 (I don't have much data or no data on the first days) and my app crashes when I get to 2015-10-02 (by this date, there is a lot of data) since I left it running all night, it crashed and I was unable to retrieve any error (logcat continued scrolling and I don't know if I can retrieve old messages from log), so I run it again today and about 1 hour after execution I got these error messages:

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/http://ift.tt/1OxDqK9) -
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/http://ift.tt/1RdbXv5) -
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/http://ift.tt/1RdbXv5) -
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/http://ift.tt/1OxDqK9) -
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/http://ift.tt/1OxDqK9) -
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/http://ift.tt/1OxDqK9) -
10-15 09:58:26.453  12045-15369/com.MyCompany.systm.qirs E/SQLiteDatabase﹕ Failed to open database '/data/data/http://ift.tt/1RdbXv5'.
    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/http://ift.tt/1RdbXv5'.
    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/http://ift.tt/1OxDqK9) -
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/http://ift.tt/1OxDqK9) -
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/http://ift.tt/1OxDo5c) -
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/http://ift.tt/1OxDo5c) -
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/http://ift.tt/1OxDo5c) -
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

I know that I have space on disk, 3.55 out of 5.10 Gb. I see an I/O error, but I'm running again the program and it's running without problems. In the end, this is service (or to whaterver I need to change it later) needs to be executed when the power is connected to the tablet, because at that point WiFi access will be available and I will need to Synchronize TO the main database AND download the pending data. I have now the broadcast receiver that detects when the power is plugged and displays a Progress Dialog but it does nothing.

So, after ALL this...

1) Any sugestions on what could be happening? (regarding my error messages)

2) Any suggestions on a better aproach to my solution?

3) Bonus points and a beer (or tacos) when you come to Tijuana, how can I launch the service when the power is connected and update a progress dialog with what's being executed

Thanks a lot for any help

Aucun commentaire:

Enregistrer un commentaire