System directories
Method | Result |
---|---|
Environment.getDataDirectory() | /data |
Environment.getDownloadCacheDirectory() | /cache |
Environment.getRootDirectory() | /system |
External storage directories
package com.feizan.android.snowball.ui.imageview; | |
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
import android.widget.RelativeLayout; | |
/** |
import android.content.Context; | |
import android.graphics.drawable.Drawable; | |
import android.util.AttributeSet; | |
import android.widget.ImageView; | |
public class DynamicImageView extends ImageView { | |
public DynamicImageView(final Context context, final AttributeSet attrs) { | |
super(context, attrs); | |
} |
import org.json.JSONArray; | |
import org.json.JSONException; | |
import org.json.JSONObject; | |
import java.util.*; | |
public class JsonHelper { | |
public static Object toJSON(Object object) throws JSONException { | |
if (object instanceof Map) { | |
JSONObject json = new JSONObject(); |
import android.graphics.Color; | |
import android.graphics.LinearGradient; | |
import android.graphics.Shader; | |
import android.graphics.drawable.Drawable; | |
import android.graphics.drawable.PaintDrawable; | |
import android.graphics.drawable.ShapeDrawable; | |
import android.graphics.drawable.shapes.RectShape; | |
import android.util.FloatMath; | |
import android.view.Gravity; |
//Android的Bitmap轉成Base64並存入資料庫的方法 | |
// 先把 bitmpa 轉成 byte | |
ByteArrayOutputStream stream = new ByteArrayOutputStream(); | |
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream ); | |
byte bytes[] = stream.toByteArray(); | |
// Android 2.2以上才有內建Base64,其他要自已找Libary或是用Blob存入SQLite | |
String base64 = Base64.encodeToString(bytes, Base64.DEFAULT); // 把byte變成base64 | |
// 再來是轉回來, 把Base64變回bytes |
String timeStamp = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(System.currentTimeMillis()); | |
// current UNIX time millsecond to yyyy-MM-dd HH:mm:ss |
/** | |
* Definition for binary tree | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |
public class Solution { |
// 判斷 app 是否有安裝 | |
private static boolean isPkgInstalled(Context context, String pkgName) { | |
PackageInfo packageInfo = null; | |
try { | |
packageInfo = context.getPackageManager().getPackageInfo(pkgName, 0); | |
} catch (PackageManager.NameNotFoundException e) { | |
packageInfo = null; | |
e.printStackTrace(); | |
} |
System directories
Method | Result |
---|---|
Environment.getDataDirectory() | /data |
Environment.getDownloadCacheDirectory() | /cache |
Environment.getRootDirectory() | /system |
External storage directories
# How do I test my APN push notification certificates (PEM key)? | |
# https://www.pubnub.com/knowledge-base/discussion/234/how-do-i-test-my-pem-key | |
# You can test your PEM key using the following command, which should hang if successful until you press enter: | |
# openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem | |
# The above tests the PEM Key in sandbox mode. For production mode, use the following command: | |
# openssl s_client -connect gateway.push.apple.com:2195 -cert pnpush.pem -key pnpush.pem | |
# You can also test your PEM Key by running the Python script below using the script below. The usage would be: | |
# python push_debug.py <CERT_PATH> <DEVICE_TOKEN> | |