数据持久化的本质就是把数据由内写到本地(硬盘中),在iOS指将数据写到沙盒文件夹下;

沙盒机制:指的就是采用沙盒文件夹的形式管理应用程序的本地文件,而且沙盒文件夹的名字是随机分配的,采用十六进制方法命名;

=======================关于沙盒目录==========================

沙盒内部构造:

测试沙盒:

属性:

  1. @interface ViewController ()
  2. @property (retain, nonatomic) IBOutlet UITextField *nameField;
  3. @property (retain, nonatomic) IBOutlet UITextField *passwordField;
  4. @property(nonatomic,retain)NSUserDefaults *user;
  5. @end

//登录按钮

  1. - (IBAction)handleLgin:(UIButton *)sender {
  2. //取出输入框中的数据
  3. NSString *name = self.nameField.text;
  4. NSString *password = self.passwordField.text;
  5. //取出用户偏好设置
  6. NSString *pName = [self.user valueForKey:@"name"];
  7. NSString *pPassword = [self.user valueForKey:@"password"];
  8. //当输入的内容和本地存储的信息相同时显示登录成功
  9. if ([name isEqualToString:pName] && [password isEqualToString:pPassword]) {
  10. NSLog(@"登陆成功");
  11. }else{
  12. NSLog(@"登录失败,请注册");
  13. }
  14. }

//注册按钮

  1. - (IBAction)handleRegister:(UIButton *)sender {
  2.  
  3. NSString *name = self.nameField.text;
  4. NSString *password = self.passwordField.text;
  5. //当不输入内容的时候提前结束方法
  6. if (name.length == 0 || password.length == 0) {
  7. NSLog(@"账户名或者密码为空,注册失败!");
  8. return;
  9. }
  10.  
  11. //本地文件中设置用户名和用户密码
  12. //设置用户名
  13. [self.user setObject:name forKey:@"name"];
  14. //设置用户密码
  15. [self.user setObject:password forKey:@"password"];
  16. //同步数据
  17. [self.user synchronize];
  18. NSLog(@"注册成功");
  19.  
  20. }

记得释放:

  1. - (void)dealloc {
  2. [_nameField release];
  3. [_passwordField release];
  4. self.user = nil;
  5. [super dealloc];
  6. }

测试结果:

————————————————————————

————————————————————————————

1.获取沙盒文件夹的路径

NSHomeDirectory() 沙盒文件的主目录,在这个文件夹下放着三个文件Document,Libralay,Tmp,其中Library 中还有两个文件Caches,Perference,系统帮我们创建五个文件存放在沙盒文件下,这五个是不能删除的

  1. NSLog(@"%@",NSHomeDirectory());

Documents: 存放一些比较重要的文件,文件大小比较小,这些都是可以有副本,此文件夹中不能有太多东西,否则在上传AppStore中会直接被拒,比如: 数据库

获取Documents 文件夹的路径

第一个参数:文件夹的名字 64行

第二个参数:搜索域,有优先级:users -->local -->network -->system

第三个参数:相对路径或者是绝对路径 YES绝对路径,NO代表相对路径

此方法最早是应用在MAC端开发的,对于PC 端可以有很多的用户,所以该方法的返回值是一个数组,但是现在这个方法应用在移动端(iOS端),而移动端用户只有一个,所以获取的路径也只有一个

  1. NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];
  2. NSLog(@"%@",documentsPath);

Library 资源库,存放的一些不太重要的文件,相对比较大,且其中有两个子文件

  1. NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)lastObject];
  2. NSLog(@"%@",libraryPath);

Caches 存放一些缓存的文件,如网页缓存,图片缓存,视频缓存,视频缓存,应用中"清除缓存"功能,清理的就是这个文件夹里面的内容

//获取Caches路径

  1. NSString *cachesPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject];
  2. NSLog(@"%@",cachesPath);

//Perferences 偏好设置,存放一些用户的信息

注意:路径是找不到的,只能通过NSUserDefaults 访问

  1. NSUserDefaults *user = [NSUserDefaults standardUserDefaults];

//perferences 中存放的都是plist 文件,在第一次设置键值对的时候,会帮你创建plist文件,如果直接取值的时候,plist 文件是没有的

赋值和取值:

  1. // [user setBool:YES forKey:@"login"];
  2. //取出BOOL值
  3. //BOOL isLogin = [user boolForKey:@"login"];
  4. // NSLog(@"%d",isLogin);

//NSUserDefaults  支持的数据类型:array,dictionary,string,data,number,bool,integer等

//NSUserDefaults  中一般存储数值类型的数据,不存放大型的数据

//模拟启动用户引导图

  1. BOOL isFirstLogin = [user boolForKey:@"login"];
  2. if (NO == isFirstLogin) {
  3. NSLog(@"第一次启动");
  4. [user setBool:YES forKey:@"login"];
  5. [user synchronize];//立即同步
  6. }else{
  7. NSLog(@"不是第一次启动");
  8. }

//Tem 存放临时文件  比如:压缩包 zip ,解压后就删除处理了

获取Tem的路径

  1. NSTemporaryDirectory();
  2. NSLog(@"%@",NSTemporaryDirectory()

NSFileManager 文件管理类,是一个文件管理工具,主要用于文件的的添加、删除、拷贝,继承自 NSObject

NSFileManager 也是一个单例类

  1. NSFileManager *fileManger = [NSFileManager defaultManager];

=======================文件的创建==========================

NSFileManager常用操作一览表:

//在Document 文件下创建一个文件 av.text

1.获取Documents 路径

  1. NSString *documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject];

2.创建av.text 的路径

  1. // stringByAppendingFormat 拼接上什么就得到什么
  2. // stringByAppendingString 拼接上什么就得到什么
  3. // stringByAppendingPathExtension 拼接的内容前加一个点
  4. // stringByAppendingPathComponent 拼接的内容前加一个 /
  1. NSString *avPath = [documentsPath stringByAppendingPathComponent:@"av"];
  2. NSLog(@"%@",avPath);

首先判断文件是否存在

  1. <span style="color:#3333ff;"> if ([fileManger fileExistsAtPath:avPath]) {
  2. NSLog(@"存在");
  3. }else{
  4. NSLog(@"不存在");
  5. </span><span style="color:#cc0000;"> //创建 av.text文件
  6. //第二个参数询问:如果路径中没有文件夹是否自动创建</span><span style="color:#3333ff;">
  7. BOOL isSuccss = [fileManger createDirectoryAtPath:avPath withIntermediateDirectories:YES attributes:nil error:nil];
  8. if (isSuccss) {
  9. NSLog(@"创建成功");
  10. }else{
  11. NSLog(@"创建失败");
  12. }
  13. }</span>

=======================文件的删除==========================

//删除文件夹

1.先判断有没有要删的文件夹存在

  1. if ([fileManger fileExistsAtPath:avPath]) {
  2. //如果存在就删除
  3. BOOL isSuccess = [fileManger removeItemAtPath:avPath error:nil];
  4. NSLog(@"%@",isSuccess ? @"删除成功":@"删除失败");
  5. }

=======================文件的拷贝==========================

//把NB.plist 拷贝到 AV 文件夹下

//NSBundle 应用程序包,我们从AppStore下载的应用就是这个包

//获取应用程序包的路径

//iOS8.0 之后,**.app 单独存放在一个文件内,**.app 这个文件只能读,不能写入,最终上传到AppStore 的包就是这个包

  1. NSString *bundlePath = [[NSBundle mainBundle]bundlePath];
  2. NSLog(@"%@",bundlePath);
  1. //1.获取NB.plist 的路径
  2. NSString *nbPath = [[NSBundle mainBundle]pathForResource:@"NB.plist" ofType:nil];
  3. //2.制造移动到沙盒Documents 文件夹下AV文件夹下NB.plist
  4. NSString *desPath = [avPath stringByAppendingPathComponent:@"NB.plist"];
  5. //3.文件拷贝
  6. if (![fileManger fileExistsAtPath:desPath]) {
  7. //第一个参数:copy之前的路径
  8. //第二个参数:要拷贝到的位置
  9. BOOL isSucess = [fileManger copyItemAtPath:nbPath toPath:desPath error:nil];
  10. NSLog(@"%@",isSucess ? @"拷贝成功":@"拷贝失败");
  11. }

=======================文件的移动==========================

  1. //从AV文件夹下,移动到Library文件夹下
  2. //1.移动之前的路径
  3. NSString *surcePath = desPath;
  4. //2.移动之后的路径
  5. NSString *libraryPath = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)lastObject];
  6.  
  7. NSString *toPath = [libraryPath stringByAppendingPathComponent:@"NB.plist"];
  8. //移动
  9. if (![fileManger fileExistsAtPath:toPath]) {
  10. BOOL isSuccess = [fileManger moveItemAtPath:surcePath toPath:toPath error:nil];
  11. NSLog(@"%@",isSuccess ? @"移动成功":@"移动失败");
  12. }
  13.  
  14. //调用简单对象的写入和读取
  15. [self simpleObjectWritwTpFileAndFromeFile];
  16. //调用归档和反档
  17. [self archiverAndArchiver];
  18.  
  19. }

=======================简单对象的写入和读取==========================

//简单对象指的是:NSString ,NSDictionary,NSData以及他们的子类

//注意:集合(NSArray,NSDictionary)的元素,必须是上面的四种基本数据类型,不能放复杂对象,才能直接进行文件的写入和读取;

字符串的写入与读取:

  1. //1.字符串的写入
  2. NSString *string = @"小韩哥真帅";
  3. //2.在Documents 文件夹下创建一个文件"text.text"
  4.  
  5. NSString *textPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject] stringByAppendingPathComponent:@"text.text"];
  6. // NSLog(@"%@",textPath);
  7.  
  8. //3.字符串的写入
  9. // 第一个参数:要写入的文件路径
  10. // 第二个参数: YES提供多线程的安全防护,NO则不提供安全防护
  11. // 第三个参数:编码的格式
  12. BOOL isSuccess = [string writeToFile:textPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
  13. NSLog(@"%@",isSuccess ? @"写入成功" :@"写入失败");
  14.  
  15. //4.字符串从文件中读取数据
  16. //第一个参数:要读取的文件路径
  17. NSString *contentString = [NSString stringWithContentsOfFile:textPath encoding:NSUTF8StringEncoding error:nil];
  18. NSLog(@"%@",contentString);

NSArray 的读取和写入:

  1. //1.准备数组
  2. NSArray *array = @[@"小韩哥",@"蔡国庆",@"周杰伦"];
  3. //2.将数组写入到 caches 文件夹下 的array.text
  4. NSString *arrayPath = [[NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"array.text"];
  5. //3.数组写入 数组写入后的文件是XML格式的
  6. isSuccess = [array writeToFile:arrayPath atomically:YES];
  7. NSLog(@"%@",isSuccess ? @"数组写入成功":@"数组写入失败");
  8.  
  9. //数组的读取
  10. NSArray *contentArray = [NSArray arrayWithContentsOfFile:arrayPath];
  11. NSLog(@"%@",contentArray);

NSDictionary 的写入和读取  写入之后变成xml格式:

  1. //1.准备字典
  2. NSDictionary *dic = @{@"男":@"小韩哥",@"明星":@"蔡国庆",@"国家主席":@"习大大"};
  3. //2.tem 文件夹下创建一个Dictionary.text 文件
  4. NSString *dictionaryPath = [NSTemporaryDirectory()stringByAppendingPathComponent:@"dictionary.text"];
  5. //3.字典的写入
  6. isSuccess = [dic writeToFile:dictionaryPath atomically:YES];
  7. NSLog(@"%@",isSuccess ? @"字典写入成功":@"字典写入失败");
  8.  
  9. //4.字典的读取
  10. NSDictionary *contentDic = [NSDictionary dictionaryWithContentsOfFile:dictionaryPath];
  11. NSLog(@"%@",contentDic);

NSData 写入和读取:

  1. NSString *dataString = @"我想对我身边人说,你该洗脚了";
  2. //1.准备NSData 对象
  3. NSData *data = [dataString dataUsingEncoding:NSUTF8StringEncoding];
  4. //2.在library 中写入 data.text 文件
  5. NSString *dataPath = [[NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"data.text"];
  6. //3.NSData 的写入
  7. isSuccess = [data writeToFile:dataPath atomically:YES];
  8. NSLog(@"%@",isSuccess ? @"NSData写入成功":@"NSData写入失败");
  9.  
  10. //4.NSData 的读取
  11. NSData *contentData = [NSData dataWithContentsOfFile:dataPath];
  12. //将二进制流转为字符串
  13. NSString *newString = [[[NSString alloc]initWithData:contentData encoding:NSUTF8StringEncoding]autorelease];
  14. NSLog(@"%@",newString);

=======================复杂对象的写入和读取==========================

复杂对象,就是Fundation 框架下不存在的数据类,也就是我们自己定义类,就叫复杂对象,复杂对象不能直接写入到文件,必须借助一些工具,NSKeyedArchiver(归档工具),读取时必须借助工具类NSKeyedUnarchiver(反归档工具)

归档和反档:

1.创建复杂对象Person

Person.h

  1. #import <Foundation/Foundation.h>
  2.  
  3. @interface Person : NSObject<NSCoding>
  4. //如果复杂对象想要完成归档和反归档,则这个对象必须遵循NSCoding协议
  5. - (void)encodeWithCoder : (NSCoder *)aCoder;
  6.  
  7. @property(nonatomic,copy)NSString *name;//姓名
  8. @property(nonatomic,copy)NSString *gender;//性别
  9. @property(nonatomic,assign)NSInteger age;//年龄
  10.  
  11. - (id)initWithName : (NSString *)name gender : (NSString *)gender age : (NSInteger )age;
  12. @end

Person.m

  1. #import "Person.h"
  2.  
  3. @implementation Person
  4. - (void)dealloc{
  5. self.name = nil;
  6. self.gender = nil;
  7. [super dealloc];
  8.  
  9. }
  10.  
  11. - (id)initWithName : (NSString *)name gender : (NSString *)gender age : (NSInteger )age{
  12. if (self = [super init]) {
  13. self.name = name;
  14. self.age = age;
  15. self.gender = gender;
  16.  
  17. }
  18. return self;
  19. }
  20. -(NSString *)description{
  21. return [NSString stringWithFormat:@"%@-%@-%ld",_name,_gender,_age];
  22. }
  23. //归档的协议方法
  24. - (void)encodeWithCoder : (NSCoder *)aCoder{
  25. //不止这个对象要归档,它的属性要被归档,此时要对它的属性进行编码
  26. [aCoder encodeObject:self.name forKey:@"name"];
  27. [aCoder encodeObject:self.gender forKey:@"gender"];
  28. [aCoder encodeObject:@(self.age) forKey:@"age"];
  29.  
  30. }
  31. //反归档的协议方法
  32. - (id)initWithCoder:(NSCoder *)aDecoder{
  33. if (self = [super init]) {
  34. //解码
  35. self.name = [aDecoder decodeObjectForKey:@"name"];
  36. self.gender = [aDecoder decodeObjectForKey:@"gender"];
  37. self.age = [[aDecoder decodeObjectForKey:@"age"]integerValue];
  38.  
  39. }
  40. return self;
  41. }
  42. @end

归档:

  1. //1.创建复杂对象Person
  2. Person *p1 = [[[Person alloc]initWithName:@"小韩哥" gender:@"男" age:20]autorelease];
  3. //2.创建归档工具
  4. NSMutableData *data = [NSMutableData data];
  5. NSKeyedArchiver *archiver = [[NSKeyedArchiver alloc]initForWritingWithMutableData:data];
  6. //3.归档
  7. //第一个参数:要被归档的对象
  8. //第二个参数:给归档对象一个key值,作为 标识,方便反归档的时候把它找回来
  9. [archiver encodeObject:p1 forKey:@"boyFriend"];
  10. //4.完成归档
  11. [archiver finishEncoding];
  12. //5.释放
  13. [archiver release];
  14.  
  15. //6.将归档后的数据文件
  16. //将文件写入到沙盒文件夹下
  17. NSString *personPath = [NSHomeDirectory() stringByAppendingPathComponent:@"person.text"];
  18. //7.将转化的data数据写入到文件中
  19. BOOL isSuccess = [data writeToFile:personPath atomically:YES];
  20. NSLog(@"%@",isSuccess ? @"写入成功":@"写入失败");

反归档:

  1. NSData *contentData = [NSData dataWithContentsOfFile:personPath];
  2. //1.创建反归档工具
  3. NSKeyedUnarchiver *unArchiver = [[NSKeyedUnarchiver alloc]initForReadingWithData:contentData];
  4. //2.读取文件(需要执行归档方法)
  5. Person *p2 = [unArchiver decodeObjectForKey:@"boyFriend"];
  6. NSLog(@"%@",p2);
  7. //3.停止反归档
  8. [unArchiver finishDecoding];
  9. //4.释放
  10. [unArchiver release];

=======================数组和复杂对象结合==========================

创建数组:

  1. Person *p3 = [[Person alloc]initWithName:@"小美女" gender:@"女" age:21];
  2. Person *p4 = [[Person alloc]initWithName:@"郭美美" gender:@"女" age:19];
  3. NSArray *pArray = @[p3,p4];
  4. [p3 release];
  5. [p4 release];

//注意:复杂对象存入数组要想完成归档,那么存入的复杂对象必须遵循NSCoding协议

//使用归档把数组写入到文件

  1. //1.创建归档工具
  2. NSMutableData *aData = [NSMutableData data];
  3. NSKeyedArchiver *nArchvier = [[NSKeyedArchiver alloc]initForWritingWithMutableData:aData];
  4. //2.使用归档对象把数组归档
  5. [nArchvier encodeObject:pArray forKey:@"array"];
  6. //3.停止归档工具
  7. [nArchvier finishEncoding];
  8. //4.释放
  9. [nArchvier release];

//文件写入到Documents 文件夹下,"array.tet"

  1. NSString *arrayPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)lastObject]stringByAppendingPathComponent:@"array.text"];
  2. isSuccess = [aData writeToFile:arrayPath atomically:YES];
  3. NSLog(@"%@",isSuccess ? @"复杂数组写入成功":@"复杂数组写入失败");

//复杂数组的读取

  1. //复杂数组的读取
  2. NSData *newData = [NSData dataWithContentsOfFile:arrayPath];
  3. //1.创建反归档工具
  4. NSKeyedUnarchiver *nUnarchvier = [[NSKeyedUnarchiver alloc]initForReadingWithData:newData];
  5. //2.通过key值将对象反归档
  6. NSArray *newArray = [nUnarchvier decodeObjectForKey:@"array"];
  7. //3.停止反归档工具
  8. [nUnarchvier finishDecoding];
  9. //4.释放
  10. [nUnarchvier release];
  11. NSLog(@"%@ %@",newArray[0],newArray[1]);

iOS中 数据持久化 UI高级_17的更多相关文章

  1. QF——iOS中数据持久化的几种方式

    数据持久化的几种方式: 一.属性列表文件: .plist文件是种XML文件.数组,字典都可以和它互相转换.数组和字典可以写入本地变成plist文件.也可以读取本地plist文件,生成数组或字典. 读取 ...

  2. IOS开发中数据持久化的几种方法--NSUserDefaults

    IOS开发中数据持久化的几种方法--NSUserDefaults IOS 开发中,经常会遇到需要把一些数据保存在本地的情况,那么这个时候我们有以下几种可以选择的方案: 一.使用NSUserDefaul ...

  3. iphone开发中数据持久化之——属性列表序列化(一)

    数据持久化是应用程序开发过程中的一个基本问题,对应用程序中的数据进行持久化存储,有多重不同的形式.本系列文章将介绍在iphone开发过程中数据持久化的三种主要形式,分别是属性列表序列号.对象归档化以及 ...

  4. iOS之数据持久化方案

    概论 所谓的持久化,就是将数据保存到硬盘中,使得在应用程序或机器重启后可以继续访问之前保存的数据.在iOS开发中,有很多数据持久化的方案,接下来我将尝试着介绍一下5种方案: plist文件(属性列表) ...

  5. iOS的数据持久化

    所谓的持久化,就是将数据保存到硬盘中,使得在应用程序或机器重启后可以继续访问之前保存的数据.在iOS开发中,有很多数据持久化的方案,接下来我将尝试着介绍一下5种方案: plist文件(属性列表) pr ...

  6. IOS - 本地数据持久化

    转:相对复杂的App仅靠内存的数据肯定无法满足,数据写磁盘作持久化存储是几乎每个客户端软件都需要做的.简单如“是否第一次打开”的BOOL值,大 到游戏的进度和状态等数据,都需要进行本地持久化存储.这些 ...

  7. iOS - OC 数据持久化

    1.Sandbox 沙箱 iOS 为每个应用提供了独立的文件空间,一个应用只能直接访问为本应用分配的文件目录,不可以访问其他目录,每个应用自己独立的访问空间被称为该应用的沙盒.也就是说,一个应用与文件 ...

  8. iOS - Swift 数据持久化

    1.Sandbox 沙箱 iOS 为每个应用提供了独立的文件空间,一个应用只能直接访问为本应用分配的文件目录,不可以访问其他目录,每个应用自己独立的访问空间被称为该应用的沙盒.也就是说,一个应用与文件 ...

  9. IOS开发--数据持久化篇之文件存储(一)

    前言:个人觉得开发人员最大的悲哀莫过于懂得使用却不明白其中的原理.在代码之前我觉得还是有必要简单阐述下相关的一些知识点. 因为文章或深或浅总有适合的人群.若有朋友发现了其中不正确的观点还望多多指出,不 ...

随机推荐

  1. python3获取网页天气预报信息并打印

    查到一个可以提供区域天气预报的url, https://www.sojson.com/open/api/weather/json.shtml?city=%E6%88%90%E9%83%BD打算用pyt ...

  2. mongoDB安装和启动

    安装: 1. mongodb(V3.4.7)安装包下载地址:https://www.mongodb.com/download-center#community 下载成功后直接运行,安装模式选择cust ...

  3. 深入理解Lambda函数及其用法

    Lambda函数又称匿名函数,匿名函数就是没有名字的函数,函数没有名字也行?当然可以啦.有些函数如果只是临时一用,而且它的业务逻辑也很简单时,就没必要非给它取个名字不可. 先来看个简单lambda函数 ...

  4. Vue结合slot插槽分发父组件内容实现高度复用、更加灵活的dialog组件

    之前写过一篇关于vue实现dialog会话框组件的文章(http://www.cnblogs.com/fozero/p/8546883.html)[http://www.cnblogs.com/foz ...

  5. Page2

    css样式表嵌入网页的4种方法: 定义标记的style属性 <标记 style="样式属性:属性值:..;"> 嵌入外部样式表 <style type=" ...

  6. sourcestress 问题解决方案

    描述:在Windows系统下,在保证GitHub上的账号和密码正确的情况下,在push时候,输入正确的账号和密码后,却是提醒无效的账户密码. 解决方法:在C:\Users\...\AppData\Lo ...

  7. PHP 5 MySQLi 函数

    在 PHP 中使用 MySQLi 函数需要注意的是:你需要添加对 MySQLi 扩展的支持. PHP MySQLi 简介 PHP MySQLi = PHP MySQL Improved! MySQLi ...

  8. Python3 注释

    确保对模块, 函数, 方法和行内注释使用正确的风格 Python中的注释有单行注释和多行注释: Python中单行注释以#开头,例如: #!/usr/bin/python3 #coding=utf-8 ...

  9. Java中使用CountDownLatch进行多线程同步

    CountDownLatch介绍 在前面的Java学习笔记中,总结了Java中进行多线程同步的几个方法: 1.synchronized关键字进行同步. 2.Lock锁接口及其实现类ReentrantL ...

  10. 安卓高级7 vitamio 视频框架 从raw文件下获取文件uri

    vitamio免费的拥有多种解码器 而且容易操作 我们先来看看原生视频播放器的怎么使用 原生的: package qianfeng.com.videoviewdemo; import android. ...