Exemplo n.º 1
0
 public boolean columnsDBParse(
     int
         idOfFile) // Функция, разбирающая xml файл с конфигами всех таблиц, сохраняющаяя названия
                   // таблиц, названия столбцов и типы столбцов
     {
   ArrayList<String[]> arrayList = new ArrayList<String[]>();
   ArrayList<String[]> typesArrayList = new ArrayList<String[]>();
   ArrayList<String> strings = new ArrayList<String>();
   ArrayList<String> typesStrings = new ArrayList<String>();
   ArrayList<String> list = new ArrayList<String>();
   try {
     XmlPullParser xpp = app.getResources().getXml(idOfFile);
     while (xpp.getEventType() != XmlPullParser.END_DOCUMENT) {
       switch (xpp.getEventType()) {
         case XmlPullParser.START_TAG:
           if (xpp.getDepth() == 2) {
             list.add(xpp.getAttributeValue(0));
           }
           if (xpp.getDepth() == 3) {
             strings.add(xpp.getAttributeValue(0));
             typesStrings.add(xpp.getAttributeValue(1));
           }
           break;
         case XmlPullParser.END_TAG:
           if (xpp.getDepth() == 2) {
             String[] helpArray = new String[strings.size()];
             helpArray = strings.toArray(helpArray);
             arrayList.add(helpArray);
             helpArray = new String[typesStrings.size()];
             helpArray = typesStrings.toArray(helpArray);
             typesArrayList.add(helpArray);
             typesStrings = new ArrayList<String>();
             strings = new ArrayList<String>();
           }
           break;
         default:
           break;
       }
       xpp.next();
     }
     this.DBcolumns = arrayList;
     this.DBtypes = typesArrayList;
     String[] arr = new String[list.size()];
     arr = list.toArray(arr);
     this.tables = arr;
   } catch (XmlPullParserException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   }
   if (this.DBcolumns == null || this.tables == null) {
     return false;
   } else {
     return true;
   }
 }
Exemplo n.º 2
0
 public byte[] imageDecode(String filename) {
   FileInputStream stream = null;
   long length = 0;
   try {
     stream = app.getResources().getAssets().openFd(filename).createInputStream();
     length = app.getResources().getAssets().openFd(filename).getLength();
   } catch (IOException e) {
     e.printStackTrace();
   }
   byte[] imageBytes = new byte[(int) length];
   if (length != 0) {
     for (int i = 0; i < length; i++) {
       try {
         imageBytes[i] = (byte) stream.read();
       } catch (IOException e) {
         e.printStackTrace();
       }
     }
   }
   return imageBytes;
 }