Example #1
0
        public static RecordStore openRecordStore(
            string recordStoreName,
            bool createIfNecessary,
            int authmode,
            bool writable)
        {
            RecordStore recordStore = (RecordStore)null;
            InputStream input       = (InputStream)null;

            try
            {
                IsolatedStorageFileStream storageFileStream = IsolatedStorageFile.GetUserStoreForAssembly().OpenFile(recordStoreName, FileMode.Open);
                try
                {
                    input = (InputStream) new MemoryInputStream((Stream)storageFileStream);
                }
                finally
                {
                    storageFileStream.Close();
                }
            }
            catch (Exception ex)
            {
                midp.JSystem.println("Previous Record Store not found");
            }
            if (input != null && input.available() >= 4)
            {
                DataInputStream dataInputStream = new DataInputStream(input);
                int             length          = dataInputStream.readInt();
                sbyte[][]       dataArray       = new sbyte[length][];
                for (int index = 0; index != length; ++index)
                {
                    int len = dataInputStream.readInt();
                    if (len > 0)
                    {
                        sbyte[] b = new sbyte[len];
                        dataInputStream.readFully(b, len);
                        dataArray[index] = b;
                    }
                }
                recordStore = new RecordStore(recordStoreName, dataArray, writable);
                dataInputStream.close();
            }
            if (recordStore == null && createIfNecessary)
            {
                recordStore = new RecordStore(recordStoreName);
            }
            return(recordStore);
        }
Example #2
0
 public static RecordStore openRecordStore(
     string recordStoreName,
     bool createIfNecessary)
 {
     return(RecordStore.openRecordStore(recordStoreName, createIfNecessary, 1, true));
 }