当前位置: 首页>>代码示例>>Java>>正文


Java LitePalApplication类代码示例

本文整理汇总了Java中org.litepal.LitePalApplication的典型用法代码示例。如果您正苦于以下问题:Java LitePalApplication类的具体用法?Java LitePalApplication怎么用?Java LitePalApplication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


LitePalApplication类属于org.litepal包,在下文中一共展示了LitePalApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildConnection

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * Build a connection to the database. This progress will analysis the
 * litepal.xml file, and will check if the fields in LitePalAttr are valid,
 * and it will open a SQLiteOpenHelper to decide to create tables or update
 * tables or doing nothing depends on the version attributes.
 * 
 * After all the stuffs above are finished. This method will return a
 * LitePalHelper object.Notes this method could throw a lot of exceptions.
 * 
 * @return LitePalHelper object.
 * 
 * @throws org.litepal.exceptions.InvalidAttributesException
 */
private static LitePalOpenHelper buildConnection() {
	LitePalAttr litePalAttr = LitePalAttr.getInstance();
	litePalAttr.checkSelfValid();
	if (mLitePalHelper == null) {
		String dbName = litePalAttr.getDbName();
		if ("external".equalsIgnoreCase(litePalAttr.getStorage())) {
			dbName = LitePalApplication.getContext().getExternalFilesDir("") + "/databases/" + dbName;
		} else if (!"internal".equalsIgnoreCase(litePalAttr.getStorage()) && !TextUtils.isEmpty(litePalAttr.getStorage())) {
               // internal or empty means internal storage, neither or them means sdcard storage
               String dbPath = Environment.getExternalStorageDirectory().getPath() + "/" + litePalAttr.getStorage();
               dbPath = dbPath.replace("//", "/");
               if (BaseUtility.isClassAndMethodExist("android.support.v4.content.ContextCompat", "checkSelfPermission") &&
                       ContextCompat.checkSelfPermission(LitePalApplication.getContext(), Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                   throw new DatabaseGenerateException(String.format(DatabaseGenerateException.EXTERNAL_STORAGE_PERMISSION_DENIED, dbPath));
               }
               File path = new File(dbPath);
               if (!path.exists()) {
                   path.mkdirs();
               }
               dbName = dbPath + "/" + dbName;
           }
		mLitePalHelper = new LitePalOpenHelper(dbName, litePalAttr.getVersion());
	}
	return mLitePalHelper;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:Connector.java

示例2: isLitePalXMLExists

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * If the litepal.xml configuration file exists.
 * @return True if exists, false otherwise.
 */
public static boolean isLitePalXMLExists() {
    try {
        AssetManager assetManager = LitePalApplication.getContext().getAssets();
        String[] fileNames = assetManager.list("");
        if (fileNames != null && fileNames.length > 0) {
            for (String fileName : fileNames) {
                if (Const.Config.CONFIGURATION_FILE_NAME.equalsIgnoreCase(fileName)) {
                    return true;
                }
            }
        }
    } catch (IOException e) {
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BaseUtility.java

示例3: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();

    mContext = getApplicationContext();

    //初始化 Bugly
    CrashReport.initCrashReport(getApplicationContext(), StaticClass.BUGLY_APP_ID, true);

    //初始化 Bmob
    Bmob.initialize(this, StaticClass.BMOB_APP_ID);

    //初始化语音识别
    SpeechUtility.createUtility(getApplicationContext(), SpeechConstant.APPID + "=" +
            StaticClass.VOICE_KEY);

    //初始化百度地图
    SDKInitializer.initialize(getApplicationContext());

    //初始化litepal
    LitePalApplication.initialize(getApplicationContext());
}
 
开发者ID:Hultron,项目名称:LifeHelper,代码行数:23,代码来源:BaseApplication.java

示例4: getConfigInputStream

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * Iterates all files in the root of assets folder. If find litepal.xml,
 * open this file and return the input stream. Or throw
 * ParseConfigurationFileException.
 * 
 * @return The input stream of litepal.xml.
 * @throws java.io.IOException
 */
private InputStream getConfigInputStream() throws IOException {
	AssetManager assetManager = LitePalApplication.getContext().getAssets();
	String[] fileNames = assetManager.list("");
	if (fileNames != null && fileNames.length > 0) {
		for (String fileName : fileNames) {
			if (Const.Config.CONFIGURATION_FILE_NAME.equalsIgnoreCase(fileName)) {
				return assetManager.open(fileName, AssetManager.ACCESS_BUFFER);
			}
		}
	}
	throw new ParseConfigurationFileException(
			ParseConfigurationFileException.CAN_NOT_FIND_LITEPAL_FILE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:LitePalParser.java

示例5: updateVersion

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * Each time database upgrade, the version of database stored in shared
 * preference will update.
 * @param extraKeyName
 * 			Pass the name of the using database usually. Pass null if it's default database.
 * @param newVersion
    *          new version of database
 */
public static void updateVersion(String extraKeyName, int newVersion) {
	SharedPreferences.Editor sEditor = LitePalApplication.getContext()
			.getSharedPreferences(LITEPAL_PREPS, Context.MODE_PRIVATE).edit();
	if (TextUtils.isEmpty(extraKeyName)) {
		sEditor.putInt(VERSION, newVersion);
	} else {
           if (extraKeyName.endsWith(Const.Config.DB_NAME_SUFFIX)) {
               extraKeyName = extraKeyName.replace(Const.Config.DB_NAME_SUFFIX, "");
           }
		sEditor.putInt(VERSION + "_" + extraKeyName, newVersion);
	}
	sEditor.apply();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:SharedUtil.java

示例6: getLastVersion

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * Get the last database version.
 * @param extraKeyName
 * 			Pass the name of the using database usually. Pass null if it's default database.
 * @return the last database version
 */
public static int getLastVersion(String extraKeyName) {
	SharedPreferences sPref = LitePalApplication.getContext().getSharedPreferences(
			LITEPAL_PREPS, Context.MODE_PRIVATE);
	if (TextUtils.isEmpty(extraKeyName)) {
		return sPref.getInt(VERSION, 0);
	} else {
           if (extraKeyName.endsWith(Const.Config.DB_NAME_SUFFIX)) {
               extraKeyName = extraKeyName.replace(Const.Config.DB_NAME_SUFFIX, "");
           }
		return sPref.getInt(VERSION + "_" + extraKeyName, 0);
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SharedUtil.java

示例7: removeVersion

import org.litepal.LitePalApplication; //导入依赖的package包/类
/**
 * Remove the version with specified extra key name.
 * @param extraKeyName
 * 			Pass the name of the using database usually. Pass null if it's default database.
 */
public static void removeVersion(String extraKeyName) {
    SharedPreferences.Editor sEditor = LitePalApplication.getContext()
            .getSharedPreferences(LITEPAL_PREPS, Context.MODE_PRIVATE).edit();
    if (TextUtils.isEmpty(extraKeyName)) {
        sEditor.remove(VERSION);
    } else {
        if (extraKeyName.endsWith(Const.Config.DB_NAME_SUFFIX)) {
            extraKeyName = extraKeyName.replace(Const.Config.DB_NAME_SUFFIX, "");
        }
        sEditor.remove(VERSION + "_" + extraKeyName);
    }
    sEditor.apply();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:SharedUtil.java

示例8: getInputStream

import org.litepal.LitePalApplication; //导入依赖的package包/类
private InputStream getInputStream() throws IOException {
	AssetManager assetManager = LitePalApplication.getContext().getAssets();
	String[] fileNames = assetManager.list("");
	if (fileNames != null && fileNames.length > 0) {
		for (String fileName : fileNames) {
			if (Const.Config.CONFIGURATION_FILE_NAME.equalsIgnoreCase(fileName)) {
				return assetManager.open(fileName, AssetManager.ACCESS_BUFFER);
			}
		}
	}
	throw new ParseConfigurationFileException(
			ParseConfigurationFileException.CAN_NOT_FIND_LITEPAL_FILE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:ModelListActivity.java

示例9: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    application = this;
    LitePalApplication.initialize(context);
    CrashReport.initCrashReport(getApplicationContext(), "e408f695f4", false);
}
 
开发者ID:mmjang,项目名称:quiz_helper,代码行数:9,代码来源:MyApplication.java

示例10: pushCmtNotify

import org.litepal.LitePalApplication; //导入依赖的package包/类
private void pushCmtNotify(CmtNotifyItem cmtNotifyItem){
    Intent mainIntent = RantActivity.newIntent(LitePalApplication.getContext(), cmtNotifyItem.getRantId());
    PendingIntent pi = PendingIntent.getActivity(this, 0, mainIntent, 0);
    Notification notification = new NotificationCompat.Builder(this)
            .setContentTitle("Rant社区")
            .setContentText(cmtNotifyItem.getUserName()+"回复你说: "+cmtNotifyItem.getCommentContent())
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.ic_user)
            .setLargeIcon(BitmapFactory.decodeResource(LitePalApplication.getContext().getResources(),R.mipmap.ic_launcher))
            .setContentIntent(pi)
            .setDefaults(NotificationCompat.DEFAULT_ALL)
            .setAutoCancel(true)
            .build();
    manager.notify(0,notification);
}
 
开发者ID:shawnsky,项目名称:RantApp,代码行数:16,代码来源:PullService.java

示例11: pushStarNotify

import org.litepal.LitePalApplication; //导入依赖的package包/类
private void pushStarNotify(StarNotifyItem starNotifyItem){
    Intent mainIntent = RantActivity.newIntent(LitePalApplication.getContext(), starNotifyItem.getRantId());
    PendingIntent pi = PendingIntent.getActivity(this, 0, mainIntent, 0);
    Notification notification = new NotificationCompat.Builder(this)
            .setContentTitle("Rant社区")
            .setContentText(starNotifyItem.getStarValue()==1?starNotifyItem.getUserName()+"赞了你,点击这里查看":starNotifyItem.getUserName()+"朝你扔了鸡蛋,点击这里查看")
            .setWhen(System.currentTimeMillis())
            .setSmallIcon(R.drawable.ic_user)
            .setLargeIcon(BitmapFactory.decodeResource(LitePalApplication.getContext().getResources(),R.mipmap.ic_launcher))
            .setContentIntent(pi)
            .setDefaults(NotificationCompat.DEFAULT_ALL)
            .setAutoCancel(true)
            .build();
    manager.notify(0,notification);
}
 
开发者ID:shawnsky,项目名称:RantApp,代码行数:16,代码来源:PullService.java

示例12: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {

    super.onCreate();

    this.mContext=getApplicationContext();
    mHandler=new Handler();
    mainThreadId=android.os.Process.myTid();      //获取主线程id

    Bmob.initialize(this, "c3afc6b5c969611f04beb79125e3ec2f");
    LitePalApplication.initialize(this);
    ZXingLibrary.initDisplayOpinion(this);

    getSharedPreferences("config",MODE_PRIVATE).edit().putBoolean("night", false).commit();
}
 
开发者ID:android-jian,项目名称:topnews,代码行数:16,代码来源:BaseApplication.java

示例13: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    //程序崩溃错误捕捉
    CrashHandler crashHandler = CrashHandler.getInstance();
    crashHandler.init(context);

    LitePalApplication.initialize(context);
}
 
开发者ID:brute121105,项目名称:weixin_auto,代码行数:11,代码来源:GlobalApplication.java

示例14: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    context = getApplicationContext();
    application = this;
    LitePalApplication.initialize(context);
    CrashReport.initCrashReport(getApplicationContext(), "398dc6145b", false);
}
 
开发者ID:mmjang,项目名称:ankihelper,代码行数:9,代码来源:MyApplication.java

示例15: onCreate

import org.litepal.LitePalApplication; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    /***
     * 初始化定位sdk,建议在Application中创建
     */
    locationService = new LocationService(getApplicationContext());
    mVibrator =(Vibrator)getApplicationContext().getSystemService(Service.VIBRATOR_SERVICE);
    SDKInitializer.initialize(getApplicationContext());
    LitePalApplication.initialize(this);

}
 
开发者ID:BeckNiu,项目名称:MyCar,代码行数:13,代码来源:LocationApplication.java


注:本文中的org.litepal.LitePalApplication类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。