Android Open Source - markj D Bhub






From Project

Back to project page markj.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project markj listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.markjmind.mobile.api.hub;
/* ww w. j ava  2  s  . c  o  m*/
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.net.Uri;
import android.provider.ContactsContract.RawContacts;
import android.util.Log;

public class DBhub {
    
  public StoreList getListToCursor(Cursor cursor){
    StoreList dataList = new StoreList();
    cursor.moveToFirst();
    if (!cursor.isAfterLast()) {
        do {
          Store store = new Store();
            for (int pos = 0;pos < cursor.getColumnCount();pos++) {
                if (cursor.getColumnName(pos) != null) {
                  try{
                    store.add(cursor.getColumnName(pos), cursor.getString(pos));
                  }catch(Exception e){
                    byte[] datas = cursor.getBlob(pos);
                    store.add(cursor.getColumnName(pos), datas);
                  }
                  
                }
            }
            dataList.add(store);
        } while (cursor.moveToNext());
    }
    cursor.close();
    return dataList;
  }
  
  public String[] getProviderArray(Class className) throws IllegalAccessException, InstantiationException{
    RawContacts d;
    Field[] fields = className.getFields();
    ArrayList list = new ArrayList();
    
    Uri uri = RawContacts.CONTENT_URI;
    List l = uri.getPathSegments();
    for(int i=0;i<l.size();i++){
      Log.i("DBhub","query:"+l.get(i).toString());
    }
    
    for(int i=0;i<fields.length;i++){
      
      int modifier = fields[i].getModifiers();
      if (Modifier.isPublic(modifier)&& Modifier.isFinal(modifier)&& Modifier.isStatic(modifier) ){// && fields[i].getType() == String.class) {
//        Log.i("DBhub",fields[i].getName()+":"+fields[i].get(null).toString());
        if(((String)(fields[i].get(null))).indexOf(".")<0){
          if(!((String)(fields[i].get(null))).equals("_count")){
            list.add((String)(fields[i].get(null)));
            if(fields[i].getType() == Integer.class){
              Log.i("DBhub",""+i+"  "+fields[i].getName()+":"+String.valueOf((Integer)fields[i].get(null)));
            }else if(fields[i].getType() == Long.class){
              Log.i("DBhub",""+i+"  "+fields[i].getName()+":"+String.valueOf((Long)fields[i].get(null)));
            }else if(fields[i].getType() == String.class){
              Log.i("DBhub",""+i+"  "+fields[i].getName()+":"+(String)fields[i].get(null));
            }
              
            
            
          }
        }
      }
    }

    if(list!=null && list.size()>0){
      String[] tempStrs = new String[list.size()];
      for(int i=0;i<list.size();i++){
        tempStrs[i]=(String)list.get(i);
        
      }
      return tempStrs;
    }else{
      return null;
    }
  }
  

  
  public StoreList query(Context context,Uri CONTENT_URI,Class className,String selection,String[] selectionArgs, String sortOrder) throws IllegalAccessException, InstantiationException{
    Cursor cursor = null;
    cursor = context.getContentResolver()
      .query(CONTENT_URI,getProviderArray(className),
          selection,
          selectionArgs, 
          sortOrder);
    StoreList dataList = getListToCursor(cursor);
    return dataList;
  }
  
  public StoreList query(Context context,Uri CONTENT_URI,String[] projection,String selection,String[] selectionArgs, String sortOrder){
    Cursor cursor = null;
    cursor = context.getContentResolver()
      .query(CONTENT_URI,projection,
          selection,
          selectionArgs, 
          sortOrder);
    StoreList dataList = getListToCursor(cursor);
    return dataList;
  }
  
  
  public int update(Context context,Uri uri, ContentValues values, String where, String[] selectionArgs){
    return context.getContentResolver().update(uri, values, where, selectionArgs);
  }
  
  
  /**
   * ???!! SQLiteDatabase close???? ???
   * @param sql
   * @param sqlDb
   * @return
   */
  public StoreList storeList(String sql, SQLiteDatabase sqlDb){
    Cursor cursor = sqlDb.rawQuery(sql, null);
    StoreList list = this.getListToCursor(cursor);
    return list;
  }
  public StoreList storeList(String sql,SQLiteOpenHelper soh){
    SQLiteDatabase db = soh.getReadableDatabase();
    StoreList list = storeList(sql,db);
    return list;
  }
  
  public void update(String sql,SQLiteOpenHelper soh){
    soh.getWritableDatabase().execSQL(sql);
    soh.close();
  }
  
}




Java Source Code List

com.markjmind.mobile.api.android.controller.JwAsyncTask.java
com.markjmind.mobile.api.android.controller.JwMapperException.java
com.markjmind.mobile.api.android.controller.JwMemberMapper.java
com.markjmind.mobile.api.android.controller.JwStringID.java
com.markjmind.mobile.api.android.controller.JwViewController.java
com.markjmind.mobile.api.android.controller.JwViewerCache.java
com.markjmind.mobile.api.android.controller.JwViewer.java
com.markjmind.mobile.api.android.controller.Jwc.java
com.markjmind.mobile.api.android.controller.OnClickListenerReceiver.java
com.markjmind.mobile.api.android.controller.ViewerXmlMapper.java
com.markjmind.mobile.api.android.exception.JwErrorCode.java
com.markjmind.mobile.api.android.exception.JwException.java
com.markjmind.mobile.api.android.json.JSONMsgString.java
com.markjmind.mobile.api.android.json.JwJOSNTreeArray.java
com.markjmind.mobile.api.android.json.JwJSONReader.java
com.markjmind.mobile.api.android.ui.JwAnimation.java
com.markjmind.mobile.api.android.ui.JwGroup.java
com.markjmind.mobile.api.android.ui.JwMenu.java
com.markjmind.mobile.api.android.ui.JwOnGroupSelect.java
com.markjmind.mobile.api.android.ui.JwTabGroup.java
com.markjmind.mobile.api.android.ui.JwTouchGroupListener.java
com.markjmind.mobile.api.android.ui.JwTouchGroup.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroupLisener.java
com.markjmind.mobile.api.android.ui.JwTouchMotionGroup.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphBoard.java
com.markjmind.mobile.api.android.ui.drawgraph.GraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.HBackLineSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.LineGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.PieGraph.java
com.markjmind.mobile.api.android.ui.drawgraph.RectGraphSkin.java
com.markjmind.mobile.api.android.ui.drawgraph.SimpleStyle.java
com.markjmind.mobile.api.android.ui.drawgraph.TextArraySkin.java
com.markjmind.mobile.api.android.ui.drawgraph.VBackLineSkin.java
com.markjmind.mobile.api.android.ui.graph.Arc.java
com.markjmind.mobile.api.android.ui.graph.BarElement.java
com.markjmind.mobile.api.android.ui.graph.BarLayout.java
com.markjmind.mobile.api.android.ui.graph.Bar.java
com.markjmind.mobile.api.android.ui.graph.IPieSkin.java
com.markjmind.mobile.api.android.ui.graph.LineLayout.java
com.markjmind.mobile.api.android.ui.graph.MeasureLayout.java
com.markjmind.mobile.api.android.ui.graph.PieArcRoundSkin.java
com.markjmind.mobile.api.android.ui.graph.PieLayout.java
com.markjmind.mobile.api.android.ui.graph.PiePercentSkin.java
com.markjmind.mobile.api.android.ui.view.JwBaseDropDown.java
com.markjmind.mobile.api.android.ui.view.JwDropDown.java
com.markjmind.mobile.api.android.ui.view.JwSlidingLayout.java
com.markjmind.mobile.api.android.ui.view.JwWheelView.java
com.markjmind.mobile.api.android.ui.view.StickerListener.java
com.markjmind.mobile.api.android.ui.view.StickerView.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewAutoScale.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewFonts.java
com.markjmind.mobile.api.android.ui.view.textview.JwTextViewWrapScale.java
com.markjmind.mobile.api.android.ui.wrapper.JwAlertDialog.java
com.markjmind.mobile.api.android.ui.wrapper.JwToast.java
com.markjmind.mobile.api.android.util.JwFile.java
com.markjmind.mobile.api.android.util.JwPreferenceList.java
com.markjmind.mobile.api.android.util.JwPreference.java
com.markjmind.mobile.api.android.util.JwSound.java
com.markjmind.mobile.api.android.util.JwTextUtils.java
com.markjmind.mobile.api.android.util.PhoneInfo.java
com.markjmind.mobile.api.android.util.WebConnection.java
com.markjmind.mobile.api.android.xml.JwDomHandler.java
com.markjmind.mobile.api.android.xml.JwDomLoader.java
com.markjmind.mobile.api.android.xml.JwEditElementHandler.java
com.markjmind.mobile.api.android.xml.JwXmlLoader.java
com.markjmind.mobile.api.android.xml.JwXmlResoure.java
com.markjmind.mobile.api.hub.ArrayJDhub.java
com.markjmind.mobile.api.hub.DBhub.java
com.markjmind.mobile.api.hub.JDhub.java
com.markjmind.mobile.api.hub.Loader.java
com.markjmind.mobile.api.hub.StoreList.java
com.markjmind.mobile.api.hub.Store.java