Bmob后端云使用步骤

时间:2023-03-09 04:12:13
Bmob后端云使用步骤

1.登录创建应用后得到id

Bmob后端云使用步骤

2.在清单文件中添加权限

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />

3.在mainactivity中添加初始化代码

public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bmob.initialize(this, "Your Application ID");

4.在gradle文件中添加仓库地址

allprojects {
repositories {
jcenter()
//Bmob的maven仓库地址,必须填写
maven { url "https://raw.github.com/bmob/bmob-android-sdk/master" }
}
}

5.在另一个gradle文件中添加依赖

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar']) compile 'cn.bmob.android:bmob-sdk:3.4.6'

6.创建JavaBean,类名要和数据库的表明一致,属性名要和表中字段一致

7.增删改查

save/delete/update/getObject