Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何使用sqlite数据库存储获取数据和检索_Java_Android_Sqlite_Android Studio_Android Sqlite - Fatal编程技术网

Java 如何使用sqlite数据库存储获取数据和检索

Java 如何使用sqlite数据库存储获取数据和检索,java,android,sqlite,android-studio,android-sqlite,Java,Android,Sqlite,Android Studio,Android Sqlite,我构建了一个带有在线服务器/管理面板的电视应用程序。我想将提取的数据从服务器保存到应用程序内存。这意味着,如果互联网不可用,应用程序将显示从sqlite数据库检索到的旧提取数据。请帮我做这件事?我已经创建了脱机数据库文件,但我不知道如何做。我正在发布活动代码,片段和脱机数据库。请帮助我配置我的问题。 提前一束感谢之情 公共类ActivityDetailCategory扩展了AppCompatActivity{ 私人回收站; 专用适配器通道适配器通道; 私人SwipeRefreshLayout

我构建了一个带有在线服务器/管理面板的电视应用程序。我想将提取的数据从服务器保存到应用程序内存。这意味着,如果互联网不可用,应用程序将显示从sqlite数据库检索到的旧提取数据。请帮我做这件事?我已经创建了脱机数据库文件,但我不知道如何做。我正在发布活动代码,片段和脱机数据库。请帮助我配置我的问题。 提前一束感谢之情

公共类ActivityDetailCategory扩展了AppCompatActivity{
私人回收站;
专用适配器通道适配器通道;
私人SwipeRefreshLayout SwipeRefreshLayout;
私有呼叫callbackCall=null;
私人int post_总计=0;
private int失败\u page=0;
私人类别;
私人间质;
int计数器=1;
私人咨询咨询;
视图;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity\u category\u details);
view=findviewbyd(android.R.id.content);
if(配置启用\u RTL\u模式){
if(Build.VERSION.SDK\u INT>=Build.VERSION\u code.JELLY\u BEAN\u MR1){
getWindow().getDecorView().setLayoutDirection(视图.布局方向\u RTL);
}
}否则{
Log.d(“日志”,“在正常模式下工作,RTL模式被禁用”);
}
loadBannerAd();
loadalad();
category=(category)getIntent().getSerializableExtra(Constant.EXTRA_OBJC);
swipeRefreshLayout=(swipeRefreshLayout)findViewById(R.id.swipe\u refresh\u layout);
swipeRefreshLayout.setColorSchemeResources(R.color.orange、R.color.green、R.color.blue、R.color.red);
recyclerView=(recyclerView)findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(新的LinearLayoutManager(本));
recyclerView.setHasFixedSize(true);
//设置数据和列表适配器
adapterChannel=new adapterChannel(this,recyclerView,new ArrayList());
recyclerView.setAdapter(适配器通道);
//在项目列表上单击
adapterChannel.setOnItemClickListener(新的adapterChannel.OnItemClickListener(){
@凌驾
公共空间单击(视图v,通道obj,内部位置){
Intent Intent=new Intent(getApplicationContext(),ActivityDetailChannel.class);
intent.putExtra(常量键通道类别、对象类别名称);
intent.putExtra(常量键通道ID,对象通道ID);
intent.putExtra(常量键通道名称,对象通道名称);
intent.putExtra(常量键通道图像,对象通道图像);
intent.putExtra(Constant.KEY\u CHANNEL\u URL,obj.CHANNEL\u URL);
intent.putExtra(常量键通道描述,对象通道描述);
星触觉(意向);
showAlad();
}
});
//当滚动到达底部时检测
adapterChannel.setOnLoadMoreListener(新adapterChannel.OnLoadMoreListener(){
@凌驾
public void onLoadMore(int当前页面){
if(post_total>adapterChannel.getItemCount()&当前页面!=0){
int next_page=当前_page+1;
请求操作(下一页);
}否则{
adapterChannel.setLoaded();
}
}
});
//在刷卡列表上
swipeRefreshLayout.setOnRefreshListener(新的swipeRefreshLayout.OnRefreshListener()){
@凌驾
公共void onRefresh(){
if(callbackCall!=null&&callbackCall.isExecuted()){
callbackCall.cancel();
}
adapterChannel.resetListData();
请求行动(1);
}
});
请求行动(1);
设置工具栏();
}
公共无效设置工具栏(){
最终工具栏=(工具栏)findViewById(R.id.Toolbar);
设置支持操作栏(工具栏);
最终ActionBar ActionBar=getSupportActionBar();
if(actionBar!=null){
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setTitle(category.category_name);
}
}
@凌驾
公共布尔onCreateOptions菜单(菜单){
getMenuInflater().充气(右菜单菜单菜单主菜单);
返回true;
}
@凌驾
公共布尔值OnOptionItemSelected(MenuItem MenuItem){
开关(menuItem.getItemId()){
案例android.R.id.home:
onBackPressed();
返回true;
案例R.id.search:
Intent Intent=新的Intent(getApplicationContext(),ActivitySearch.class);
星触觉(意向);
返回true;
违约:
返回super.onOptionsItemSelected(菜单项);
}
}
私有void displayApiResult(最终列表通道){
适配器通道。插入数据(通道);
swipeProgress(假);
if(channels.size()==0){
showNoItemView(true);
}
}
私有无效请求PostAPI(最终整版页码){
ApiInterface ApiInterface=RestAdapter.createAPI();
callbackCall=apiInterface.getCategoryDetailsByPage(category.cid,page\u no,Config.LOAD\u MORE);
callbackCall.enqueue(新的Callback(){
@凌驾
公共void onResponse(调用、响应){
CallbackDetailCategory resp=response.body();
如果(resp!=null&&resp.status.equals(“ok”)){
post_总计=相应计数_总计;
显示结果(相应职位);
}埃尔斯