`
- 浏览:
634421 次
-
android-键值对java Properties
- java的Properties可以操作一个键值对类型数据保存的文件,同样可以在android进行保存数据。
- 可以作为工具类保存数据<pre name="code" class="java"></pre>
-
- import java.io.File;
- import java.io.FileInputStream;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.util.Properties;
- import android.content.Context;
- import android.content.res.AssetManager;
- public class PropertiesConfig extends Properties {
- public static final String configPath = "config" + File.separator
- + "client_config.properties";
- public static final String KEY_user_valid_code = "KEY_user_valid_code";
- private static Context mContext;
- private PropertiesConfig() {
- };
- private static PropertiesConfig mPro;
- public static PropertiesConfig getInstance(Context mContext) {
- if (PropertiesConfig.mContext == null || mPro == null) {
- PropertiesConfig.mContext = mContext;
- try {
-
- File file=new File(configPath);
- file.mkdirs();
- file.createNewFile();
- } catch (IOException e1) {
-
- e1.printStackTrace();
- }
- PropertiesConfig pro = new PropertiesConfig();
-
- AssetManager am = mContext.getAssets();
- try {
- InputStream is = am.open(configPath);
- pro.load(is);
- is.close();
- } catch (Exception e) {
-
- e.printStackTrace();
- }
- mPro = pro;
- return pro;
- }
- return mPro;
- }
- @Override
- public Object setProperty(String key, String value) {
- super.setProperty(key, value);
- try {
-
- this.store(new FileOutputStream(PropertiesConfig.configPath),
- "utf-8");
- } catch (FileNotFoundException e) {
-
- e.printStackTrace();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- return value;
- }
-
- public Object put(String key, String value) {
- super.put(key, value);
- try {
-
- this.store(new FileOutputStream(PropertiesConfig.configPath),
- "utf-8");
- } catch (FileNotFoundException e) {
-
- e.printStackTrace();
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- return value; }
- }
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
NULL 博文链接:https://b275518834201204034558.iteye.com/blog/1547588
Android存取键值对的代码例子。通过利用SharedPreferences和Properties两种方式,演示了如何实现键值对保存和读取的功能。
java 改变Properties文件中的键值 java 改变Properties文件中的键值
gulp-filter-java-properties Node 包的包装。 执行键值字符串替换,类似于 Maven 资源插件。用法首先,安装gulp-filter-java-properties作为开发依赖: npm install --save-dev gulp-filter-java-properties 然后,...
eclipse关联源码 步骤一:把该源码下载下来 步骤2:找到你安装sdk的...步骤四:找到项目android.jar, 然后---》properties-->java source attachment--->点External Folder 找到 刚才新建的sources目录即可 最后重启!
java 枚举遍历键值对 属性类Properties 类加载器
resolver-status.properties
Project--Properties--Java Build Path--Libraries-- Add External JARs(add jars),将主目录下的jar文件(4个,djep-1.0.0.jar, jep2.3.0.jar, peersim1.0.5.jar,peersimdclet.jar)都添加进去。Libraries中才是程序...
右键此包---->Properties,在弹出的窗口中,选择 Java Source Attachment------>External Location------>External File, 在folder中选择源码包解压后所在文件夹,便成功在Eclipse中绑定Android源代码。
androidjava通用代码关于用properties存储打印的Log.zip
完美解决can't find bundle for base name messages.AndroidJpsBundle.locale zh_CN这个错误。 包含android-jps-plugin.jar和AndroidJpsBundle.properties,两个文件,其中jar包里也含有AndroidJpsBundle.properties
Android 的 android-26 SDK地安装好的。目录如下 android-stubs-src.jar android.jar build.prop data framework.aidl optional package.xml sdk.properties skins source.properties templates uiautomator.jar
JSON Schema 生成库——json-schema-inferrer(java版).rar
jsp+servlet+eclipse+mysql(包含源码和数据库),含增删改查功能,导入数据库,就可以运行。 各层的类如下: ...---clientDao.java ---clientDaoImp.java ...---db.properties com.jsp.vo ---Client.java
LOCAL_STATIC_JAVA_LIBRARIES += android-junit-report-dev-FM2tests include $(CLEAR_VARS) LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := android-junit-report-dev-FM2tests:libs/android-junit-report-dev.jar ...
jQuery.i18n.properties是一款轻量级的jQuery国际化插件,能实现Web前端的国际化
microlog4android-1.0.0 文件和microlog.properties文件下载,便于进行日志的管理和下载用途,方便进行日志的输出文件
非常实用的读取配置文件的小工具,专门读取WEB-INF下文件夹中的properties文件,代码简洁、亲测没有问题,适用范围广,任何类中都可调用,传入Key及可得到Value
jquery-i18n-properties-1.0.9 多语言源代码及用例,可以参考用例的写法
android-15-src.rar 右键项目中的android.jar-->Properties--->java source attachmet --->external File -->选择文件即可,可以看到android 的class文件