随笔分类 - Android
摘要:delete from TableName; //清空数据update sqlite_sequence SET seq = 0 where name ='TableName';//自增长ID为0
阅读全文
摘要:// 随机产生 1-9的整数 int randomId = 1 + new Random().nextInt(9);// 从 R.drawable类中获得相应资源id的File对象 Field field = R.drawable.class.getDeclare...
阅读全文
摘要:try { // 获取手机上的所有网络设备(wifi模块) Enumeration netInterface = NetworkInterface.getNetworkInterfaces(); // 枚举所有的网络设备 ...
阅读全文
摘要:private Handler handler = new Handler( );private Runnable runnable = new Runnable( ) {public void run ( ) {update( );handler.postDelayed(this,1000); /...
阅读全文
摘要:在实际工作中,事先写好的布局文件往往不能满足我们的需求,有时会根据情况在代码中自定义控件,这就需要用到LayoutInflater。LayoutInflater在Android中是“扩展”的意思,作用类似于findViewById(),不同的是LayoutInflater是用来获得布局文件对象的,而...
阅读全文
摘要:=====================转自:http://www.cnblogs.com/Excellent/archive/2011/11/19/2254888.html=====================SQLite简介Google为Andriod的较大的数据处理提供了SQLite,他...
阅读全文
摘要:经常我们需要使用一些事先做好内容的数据库,比如字典等, 这就要加载已有的数据库文件,通常把它们放在assets 或者raw中,在程序运行时copy到程序内部空间,但是这样有个缺点,当文件较大时会占用较长的时间,用户难免会有点小着急。我们可以这样HACK来把copy的环节省去:1 把数据库文件(如MY...
阅读全文
摘要:private SQLiteDatabase stuDb; /** * 查询数据库 * openOrCreateDatabase(数据库路径,数据库名) * rawQuery(Sql语句,参数) */ pri...
阅读全文
摘要:/** * 将asseet当中的数据库文件拷到程序目录 * @param activity 当前Activity * @param filePath 你的程序目录 getApplicationContext()...
阅读全文
摘要:// 获取当前程序路径 getApplicationContext().getFilesDir().getAbsolutePath();// 获取该程序的安装包路径 String path=getApplicationContext().getPackageResourcePath(...
阅读全文
摘要:正常退出System.exit(0);暴力退出Process.killProcess(Process.myPid());
阅读全文
摘要:public class ZhengZe { public static void main(String[] args) { String b = "postData{1,2,3}"; System.out.println(b+"\t"+b.length()); ...
阅读全文
摘要:配置清单文件加上权限private String getLocalIpAddress() { int paramInt = ((WifiManager) getSystemService("wifi")).getConnectionInfo().getIpAddress(); ...
阅读全文
摘要:class MyView extends View { float phase; PathEffect[] effects = new PathEffect[7]; int[] colors; private Paint paint; Path path; pub...
阅读全文
摘要:懒得打字/** * 发送post请求传递Json */ public void jieXi() { new Thread(new Runnable() { public void run() { // Json中...
阅读全文
摘要:懒得打字了,直接把这个类的代码贴上来public class MainActivity extends Activity { private TextView tv_shuju; private ListView listView; private ArrayAdapter ada...
阅读全文
摘要:private void saveFullImage(String str) { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); // 文件夹aaaa File path1 =...
阅读全文
摘要:服务类,一定要在清单文件中注册public class lightService extends Service { private boolean ifrun = false; @Override public IBinder onBind(Intent intent) { ...
阅读全文
摘要:// 判断sd卡是否存在 boolean sdCardExist = Environment.getExternalStorageState().equals( android.os.Environment.MEDIA_MOUNTED); /...
阅读全文
摘要:1 public class OneJsonActivity extends Activity { 2 3 String JsonData = "[{\"id\":[\"386\",\"381\",\"379\",\"377\"],\"num\":[\"386\",\"381\",\"3...
阅读全文

浙公网安备 33010602011771号